You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the sake of simplicity we omit the full qualified class names in the following table. All class names start with the
prefix net.ssehub.kernel_haven.metric_haven.code_metrics. Most of the metrics support variability weights.
INTERNAL: Counts the number of variables used inside the function
EXTERNAL: Counts the number of variables used outside the function
EXTERNAL_WITH_BUILD_VARS: Counts the number of variables used outside the function (considers variables of the build model (requires provided build model))
All variations may be combined with any of the variability weights from below.
CyclomaticComplexityMetric
2,593
Measures the Cyclomatic Complexity of code functions.
metrics.cyclomatic_complexity.measured_type:
MCCABE: Measures the cyclomatic complexity of classical code elements as defined by McCabe; uses a simplification that only the following keywords will be counted: if, for, while, case.
VARIATION_POINTS: Measures the cyclomatic complexity of variation points only; uses a simplification that only the following keywords will be counted: if, elif.
ALL: MCCABE + VARIATION_POINTS
All variations except for MCCABE may be combined with any of the variability weights from below.
LoCMetric
10
Measures the number of lines or statements (single line statement, loop, ..) per function.
metrics.loc.measured_type:
SCOC: Measures the non-CPP statements (also if they are surrounded by an CPP-block).
SCOF: Measures the lines of feature code (only statements surrounded by CPP-blocks, if a variability model is passed, it checks if at least one variable of the variability model is used in the CPP-block)
SCOC_COMMENT_RATIO: Measures the ratio of comments in SCOC.
SCOF_COMMENT_RATIO: Measures the ratio of comments in SCOF.
PSCOF: SCOF / SCOC
LOC: Measures the non-CPP lines of code (also of they are surrounded by an CPP-block).
LOF: Measures the lines of feature code (only lines surrounded by CPP-blocks (including if, else, endif), if a variability model is passed, it checks if at least one variable of the variability model is used in the CPP-block)
LOC_COMMENT_RATIO: Measures the ratio of comments in LOC.
LOF_COMMENT_RATIO: Measures the ratio of comments in LOF
PLOF: LOF / LOC
NestingDepthMetric
5,186
Measures the number of nested control structures.
metrics.nesting_depth.measured_type:
CLASSIC_ND_MAX: Maximum depth (within a function) of non-CPP structures.
CLASSIC_ND_AVG: Average depth (within a function) of non-CPP structures.
VP_ND_MAX: Maximum depth (within a function) only of CPP structures.
VP_ND_AVG: Average depth (within a function) only of CPP structures.
COMBINED_ND_MAX: Maximum depth (within a function) of non-CPP and CPP structures.
COMBINED_ND_AVG: Average depth (within a function) of non-CPP and CPP structures.
All variations except for CLASSIC_ND_* may be combined with any of the variability weights from below.
EigenVectorCentrality
12,968
Eigenvector centrality (= recusrive version of FanInOut-metric).
This metric uses the FanInOut metric and re-uses its
metrics.fan_in_out.type setting. Please refer to the FanInOut-metric for a description.
FanInOutMetric
12,968
Measures the number of incoming/outgoing function calls per function
metrics.fan_in_out.type:
CLASSICAL_FAN_IN_GLOBALLY: Measures how often a function is called from anywhere in the code (independently of CPP-blocks).
CLASSICAL_FAN_IN_LOCALLY: Measures how often a function is called from inside the same file (independently of CPP-blocks).
CLASSICAL_FAN_OUT_GLOBALLY: Measures how many other functions (from anywhere in the code) a function is calling (independently of CPP-blocks).
CLASSICAL_FAN_OUT_LOCALLY: Measures how many other functions (in the same file) a function is calling (independently of CPP-blocks).
VP_FAN_IN_GLOBALLY: Measures how often a function is called from anywhere in the code (only if nested in CPP-Blocks).
VP_FAN_IN_LOCALLY: Measures how often a function is called from inside the same file (only if nested in CPP-Blocks).
VP_FAN_OUT_GLOBALLY: Measures how many other functions (from anywhere in the code) a function is calling (only in CPP-blocks).
VP_FAN_OUT_LOCALLY: Measures how many other functions (in the same file) a function is calling (only in CPP-blocks).
DEGREE_CENTRALITY_IN_GLOBALLY: Measures No. of features + 1 when function is called from anywhere in the code.
DEGREE_CENTRALITY_IN_LOCALLY: Measures No. of features + 1 when function is called from the same file.
DEGREE_CENTRALITY_OUT_GLOBALLY: Measures No. of features + 1 for function calls to other functions to anywhere in code.
DEGREE_CENTRALITY_OUT_LOCALLY: Measures No. of features + 1 for function calls to other functions in the same file.
DEGREE_CENTRALITY_OUT_NO_STUB_*: Degree centrality variations that do not count calls to empty function stubs (functions with an empty body).
DEGREE_CENTRALITY_OUT_*_NO_EXTERNAL_VPS_*: Degree centrality variations that do not count features that are surrounded around called functions (external #ifdefs).
DEGREE_CENTRALITY_* variations may be combined with any of the variability weights from below.
TanglingDegreeFunctionMetric
2,592
Measures tangling degree values for each CPP block with an expression (no else statements) and sums them up for each function.
metrics.tangling_degree.measured_type:
TD_ALL: Considers all variation points also those with invisible expressions, i.e., else-blocks (default)
TD_VISIBLE: Considers only visible variation points (i.e., no else-blocks) and expressions of previous siblings (i.e., negated conditions of previous conditions for elifs)
Both variations support any of the variability weights from below.
BlocksPerFunctionMetric
2
Measures the numbers of VP blocks in a function, independent whether they are nested or not.
metrics.blocks_per_function.measured_block_type:
BLOCK_AS_ONE: if, elif, else are counted as one block
SEPARATE_PARTIAL_BLOCKS: if, elif, else are treated as three independent blocks
This metric cannot be combined with the variability weights from below.
UndisciplinedPreprocessorUsage
1
Measures the numbers of C-preprocessor statements, that break statements or control structures into multiple peaces.
This metric has no individual settings and may not be combined with any variability weight from below.
Total
42,800
Supported Variability Weights
For the sake of simplicity we omit the full qualified names of the weights in the following table. All names start with the
prefix metrics.function_measures..
Weight (Setting)
Description
Values
consider_scattering_degree
Weights features used in code blocks based on their scattering degree (how often they are used in code).
NO_SCATTERING: Won't consider scattering degree of measured variables
SD_VP: Weights each variable with its variation point scattering (e.g., no of ifdefs a variable is used in).
SD_FILE: Weights each variable with its file scattering.
consider_ctcr
Weights features based on their usage in cross-tree constraints of the variability model. If a feature is not involved in any constraints, the result is 0 indicating that selecting the feature has no impact on other features.
NO_CTCR: Won't consider constraints of the variability model
INCOMIG_CONNECTIONS: Weights each variable with the no. of distinct variables, specifying a constraint TO the measured variable.
OUTGOING_CONNECTIONS: Weights each variable with the no. of distinct variables, referenced in constraints defined BY the measured variable.
ALL_CTCR: Weights each variable with the (INCOMIG_CONNECTIONS + OUTGOING_CONNECTIONS).
consider_feature_definition_distance
Weights features based on the distance where they are defined (location of the variability model) and their usage (location of the measured code artifact). Requires an extracted variability model, which provides information where in the file system a feature was defined. If code file and variability model are placed in same folder, the result is 0 indicating a perfect cohesion of variability.
NO_DISTANCE: Won't consider feature distances
SHORTEST_DISTANCE: Computes the shortest way to traverse from the folder of the currently measured code artifact to the folder containing the definition of the feature in the variability model. If multiple definitions exist (e.g., supported by Kconfig), the shortest path is used. If variables is defined in same folder (but different file) as the code file, the value is 0. Consequently, such features won't be considered when computing a code metric from above.
consider_feature_types
Weights features based on their data type. Requires an extracted variability model.
NO_TYPE_MEASURING: Won't consider any weights with respect to the type of the feature.
TYPE_WEIGHTS_BY_FILE: Requires the configuration of weights per feature type in the configuration file (via metrics.function_measures.weight_definitions). Each type weight is defined via a 2-tuple separated by a colon in the form of name:value.
consider_feature_hierarchies
Weights features based on their hierarchy level as models in the variability model. Requires an extracted variability model, which provides information of the hierarchy.
NO_HIERARCHY_MEASURING: Won't consider any feature hierarchies.
HIERARCHY_WEIGHTS_BY_FILE: Requires the configuration of hierarchy weights in the configuration file (via metrics.function_measures.hierarchy_weight_definitions). Each hierarchy type is defined via a 2-tuple separated by a colon in the form of name:value. Supported hierarchy types are top, intermediate, and leaf
HIERARCHY_WEIGHTS_BY_LEVEL: The hierarchy (level) is directly used as weight.
consider_varmodel_structures
Weights features based on the number of childred / parents they have.
NO_STRUCTURAL_MEASUREMENT: Won't consider any feature structures.
NUMBER_OF_CHILDREN: Counts the number of (direct) children a features has.
COC: Count all edges (inspired by CoC).
feature_sizes
Computes the Lines of Code controlled by a feature, i.e., the feature size.
NO_FEATURE_SIZES: Disables this weight.
POSITIVE_SIZES: Counts the Lines of Code (statements) controlled by the positive form of a feature, i.e., which are included if the feature is selected.
TOTAL_SIZES: Counts all statements, which are controlled by the feature in any form, i.e., Lines that are included either if the feature is selected or deslected.
Dependencies
In addition to KernelHaven, this plugin has the following dependencies:
A code extractor, which extracts an AST (SyntaxElements).
A variability model extractor, which provides support for
Cross-tree constraint ratios for CTCR options.
Location of feature definitions for feature_definition_distance options.
A build model extractor, for some of the options (see description from above).
All variations of one code function metric, requires analysis.metrics_runner.metrics_class as additional parameter so specify the metric to be executed.