Showing 229 of 962 total issues
Function _get_rules_variables
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def _get_rules_variables(self, base_dir):
for dirpath, dirnames, filenames in os.walk(base_dir):
dirnames.sort()
filenames.sort()
for filename in filenames:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_profileruleids
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def get_profileruleids(xccdftree, profile_name):
ruleids = []
while profile_name:
profile = None
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if subkey_counts[our_key] > 1:
print("Duplicated key " + our_key + " in " + section + " of " + file_path)
return True
Function get_all_resolved_profiles_by_id
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_all_resolved_profiles_by_id(
Function compare_platforms
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def compare_platforms(self, old_rule, new_rule, old_benchmark, new_benchmark, identifier):
entries = [{
"benchmark": old_benchmark,
"rule": old_rule,
"cpe": []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if TRACE_PARSE: print('ast10:', repr(ast))
break
Avoid deeply nested control flow statements. Open
if negated is None:
negated = arg
else:
negated = None
break
Avoid deeply nested control flow statements. Open
if arg in target.args:
pass
elif narg in target.args:
if remove is None:
remove = narg
Function get_rule_dir_remediations
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def get_rule_dir_remediations(dir_path, remediation_type, product=None):
"""
Gets a list of remediations of type remediation_type contained in a
rule directory. If product is None, returns all such remediations.
If product is not None, returns applicable remediations in order of
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if our_line:
# Not supposed to be possible to have multiple keys
# matching the same value in this file. We should've
# already fixed this with fix-rules.py's duplicate_subkeys.
msg = "File {0} has duplicated key {1}: {2} vs {3}"
Function which
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def which(program):
fpath, fname = os.path.split(program)
if fpath:
if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
return program
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function compose_ds
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def compose_ds(
Function get_rule_dir_sces
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def get_rule_dir_sces(dir_path, product=None):
"""
Get a list of SCEs contained in a rule directory. If product is None,
returns all SCEs. If product is not None, returns applicable SCEs in
order of priority:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if not ref.text.startswith("SRG-"):
rhid.append(ref.text)
else:
srgs.append(ref.text)
for id in rhid:
Function create_tailoring
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def create_tailoring(args):
benchmark_root = ET.parse(args.manual).getroot()
known_rules = get_implemented_stigs(args.product, args.root, args.build_config_yaml,
args.reference, args.json, args.resolved_rules_dir,
args.build_root)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, product_yaml_path, input_dir, output_dir, rules_dir, profiles_dir,
Avoid deeply nested control flow statements. Open
if nonempty_line and file_contents[line_num][0] != ' ':
break
line_num += 1
Avoid deeply nested control flow statements. Open
if TRACE_PARSE: print('ast9:', repr(ast))
ast = ast[0]
Avoid deeply nested control flow statements. Open
if len(file_contents[line_num]) > 0 and file_contents[line_num][0] != ' ':
break
line_num += 1
Function add_platform_to_benchmark
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def add_platform_to_benchmark(root, cpe_regex):
benchmark_query = ".//ds:component/xccdf-1.2:Benchmark"
benchmarks = root.findall(benchmark_query, PREFIX_TO_NS)
if not benchmarks:
msg = (
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"