mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
Address review comments.
This commit is contained in:
@@ -7,15 +7,11 @@ import semmle.code.Location
|
||||
|
||||
/** Each element in a configuration file has a location. */
|
||||
abstract class ConfigLocatable extends @configLocatable {
|
||||
/** Retrieve the source location for this element. */
|
||||
Location getLocation() {
|
||||
configLocations(this, result)
|
||||
}
|
||||
/** Gets the source location for this element. */
|
||||
Location getLocation() { configLocations(this, result) }
|
||||
|
||||
/** The file associated with this element. */
|
||||
File getFile() {
|
||||
result = getLocation().getFile()
|
||||
}
|
||||
/** Gets the file associated with this element. */
|
||||
File getFile() { result = getLocation().getFile() }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
abstract string toString();
|
||||
@@ -26,76 +22,49 @@ abstract class ConfigLocatable extends @configLocatable {
|
||||
* for applications, such as the port, name or address of a database.
|
||||
*/
|
||||
class ConfigPair extends @config, ConfigLocatable {
|
||||
/** Gets the name of this ConfigPair, if any. */
|
||||
ConfigName getNameElement() { configNames(result, this, _) }
|
||||
|
||||
/** If this ConfigPair has a name element, return it. */
|
||||
ConfigName getNameElement() {
|
||||
configNames(result, this, _)
|
||||
}
|
||||
|
||||
/** If this ConfigPair has a value element, return it. */
|
||||
ConfigValue getValueElement() {
|
||||
configValues(result, this, _)
|
||||
}
|
||||
/** Gets the value of this ConfigPair, if any. */
|
||||
ConfigValue getValueElement() { configValues(result, this, _) }
|
||||
|
||||
/**
|
||||
* If this ConfigPair has a name element, return its string value.
|
||||
* Otherwise return the empty string.
|
||||
* Gets the string value of the name of this ConfigPair if
|
||||
* it exists and the empty string if it doesn't.
|
||||
*/
|
||||
string getEffectiveName() {
|
||||
if exists(getNameElement()) then
|
||||
result = getNameElement().getName()
|
||||
else
|
||||
result = ""
|
||||
if exists(getNameElement()) then result = getNameElement().getName() else result = ""
|
||||
}
|
||||
|
||||
/**
|
||||
* If this ConfigPair has a value element, return its string value.
|
||||
* Otherwise return the empty string.
|
||||
* Gets the string value of the value of this ConfigPair if
|
||||
* it exists and the empty string if it doesn't.
|
||||
*/
|
||||
string getEffectiveValue() {
|
||||
if exists(getValueElement()) then
|
||||
result = getValueElement().getValue()
|
||||
else
|
||||
result = ""
|
||||
if exists(getValueElement()) then result = getValueElement().getValue() else result = ""
|
||||
}
|
||||
|
||||
/** A printable representation of this ConfigPair. */
|
||||
override string toString() {
|
||||
result = getEffectiveName() + "=" + getEffectiveValue()
|
||||
}
|
||||
/** Gets a printable representation of this ConfigPair. */
|
||||
override string toString() { result = getEffectiveName() + "=" + getEffectiveValue() }
|
||||
}
|
||||
|
||||
/** The name element of a ConfigPair. */
|
||||
class ConfigName extends @configName, ConfigLocatable {
|
||||
/** Gets the name as a string. */
|
||||
string getName() { configNames(this, _, result) }
|
||||
|
||||
/** Returns the name as a string. */
|
||||
string getName() {
|
||||
configNames(this, _, result)
|
||||
}
|
||||
|
||||
/** A printable representation of this ConfigName. */
|
||||
override string toString() {
|
||||
result = getName()
|
||||
}
|
||||
/** Gets a printable representation of this ConfigName. */
|
||||
override string toString() { result = getName() }
|
||||
}
|
||||
|
||||
/** The value element of a ConfigPair. */
|
||||
class ConfigValue extends @configValue, ConfigLocatable {
|
||||
/** Gets the value as a string. */
|
||||
string getValue() { configValues(this, _, result) }
|
||||
|
||||
/** Returns the value as a string. */
|
||||
string getValue() {
|
||||
configValues(this, _, result)
|
||||
}
|
||||
|
||||
/** A printable representation of this ConfigValue. */
|
||||
override string toString() {
|
||||
result = getValue()
|
||||
}
|
||||
/** Gets a printable representation of this ConfigValue. */
|
||||
override string toString() { result = getValue() }
|
||||
}
|
||||
|
||||
/** A Java property is a name-value pair in a .properties file. */
|
||||
class JavaProperty extends ConfigPair {
|
||||
JavaProperty() {
|
||||
getFile().getExtension() = "properties"
|
||||
}
|
||||
}
|
||||
class JavaProperty extends ConfigPair { JavaProperty() { getFile().getExtension() = "properties" } }
|
||||
|
||||
Reference in New Issue
Block a user