C++: Various renamings

This commit is contained in:
Calum Grant
2024-11-11 15:27:58 +00:00
parent 34ee947d2f
commit fb82d435b5
4 changed files with 19 additions and 19 deletions

View File

@@ -20,8 +20,8 @@ class SyntaxError extends CompilerError {
* A cannot open file error.
* Typically this is due to a missing include.
*/
class CannotOpenFile extends CompilerError {
CannotOpenFile() { this.hasTag(["cannot_open_file", "cannot_open_file_reason"]) }
class CannotOpenFileError extends CompilerError {
CannotOpenFileError() { this.hasTag(["cannot_open_file", "cannot_open_file_reason"]) }
string getIncludedFile() {
result = this.getMessage().regexpCapture("cannot open source file '([^']+)'", 1)

View File

@@ -47,16 +47,16 @@ abstract class SuccessMetric extends ExtractionMetric {
* A metric used to report database quality.
*/
class QualityMetric extends Metric {
BaseMetric base_metric;
SuccessMetric relative_metric;
BaseMetric baseMetric;
SuccessMetric relativeMetric;
QualityMetric() {
base_metric = relative_metric.getBaseline() and this = "Percentage of " + relative_metric
baseMetric = relativeMetric.getBaseline() and this = "Percentage of " + relativeMetric
}
float getValue() {
base_metric.getValue() > 0 and
result = 100.0 * relative_metric.getValue() / base_metric.getValue()
baseMetric.getValue() > 0 and
result = 100.0 * relativeMetric.getValue() / baseMetric.getValue()
}
}
@@ -70,8 +70,8 @@ module RankMetric<RankedMetric M> {
/** Various metrics we want to report. */
module CppMetrics {
class CompilationUnits extends BaseMetric {
CompilationUnits() { this = "compilation units" }
class Compilations extends BaseMetric {
Compilations() { this = "compilations" }
override int getValue() { result = count(Compilation c) }
}
@@ -92,14 +92,14 @@ module CppMetrics {
override SourceFiles getBaseline() { any() }
}
class CompilationUnitsWithoutErrors extends SuccessMetric {
CompilationUnitsWithoutErrors() { this = "compilation units without errors" }
class CompilationsWithoutErrors extends SuccessMetric {
CompilationsWithoutErrors() { this = "compilations without errors" }
override int getValue() {
result = count(Compilation c | not exists(Diagnostic d | d.getFile() = c.getAFileCompiled()))
}
override CompilationUnits getBaseline() { any() }
override Compilations getBaseline() { any() }
}
class Expressions extends BaseMetric {
@@ -186,7 +186,7 @@ module CppMetrics {
override int getValue() {
result =
sum(File f | | f.getMetrics().getNumberOfLinesOfCode()) -
count(File file, int line | errorLine(file, line))
count(File f, int line | errorLine(f, line))
}
override LinesOfCode getBaseline() { any() }
@@ -209,7 +209,7 @@ module CppMetrics {
class Includes extends BaseMetric {
Includes() { this = "#include directives" }
override int getValue() { result = count(Include i) + count(CannotOpenFile e) }
override int getValue() { result = count(Include i) + count(CannotOpenFileError e) }
}
class SucceededIncludes extends SuccessMetric {
@@ -240,11 +240,11 @@ module CppMetrics {
string include_text;
MissingIncludeCount() {
exists(CannotOpenFile e | e.getIncludedFile() = include_text) and
exists(CannotOpenFileError e | e.getIncludedFile() = include_text) and
this = "Failed to include '" + include_text + "'"
}
int getValue() { result = count(CannotOpenFile e | e.getIncludedFile() = include_text) }
int getValue() { result = count(CannotOpenFileError e | e.getIncludedFile() = include_text) }
string getIncludeText() { result = include_text }
}

View File

@@ -1,5 +1,5 @@
| Percentage of calls with a target | 50.0 |
| Percentage of compilation units without errors | 50.0 |
| Percentage of compilations without errors | 50.0 |
| Percentage of expressions with a known type | 30.0 |
| Percentage of functions without errors | 75.0 |
| Percentage of lines of code without errors | 63.1578947368421 |

View File

@@ -1,8 +1,8 @@
| #include directives | 2 |
| calls | 2 |
| calls with a target | 1 |
| compilation units | 2 |
| compilation units without errors | 1 |
| compilations | 2 |
| compilations without errors | 1 |
| compiler errors | 10 |
| expressions | 10 |
| expressions with a known type | 3 |