Showing 231 of 1,039 total issues
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.
Only returns SCEs which exist.
- 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 shorten_relevant_ref
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def shorten_relevant_ref(ref_format, ref):
match = re.match(ref_format, ref)
if match:
groups = []
for refpart in match.groups():
- 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 has_invalid_cce
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def has_invalid_cce(rule_path, rule, rule_lines):
if 'identifiers' in rule and rule['identifiers'] is not None:
for i_type, i_value in rule['identifiers'].items():
if i_type[0:3] == 'cce':
if not cce.is_cce_value_valid("CCE-" + str(i_value)):
- 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 fix_file_prompt
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def fix_file_prompt(path, product_yaml, func, args):
file_contents = open(path, 'r').read().split("\n")
new_file_contents = _fixed_file_contents(path, file_contents, product_yaml, func)
changes = file_contents != new_file_contents
- 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__(
Function fix_prefix_cce
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def fix_prefix_cce(file_contents, yaml_contents):
section = 'identifiers'
prefixed_identifiers = []
- 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 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"
Further reading
Function reboot_domain
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def reboot_domain(domain, domain_ip, ssh_port):
timeout = 300 # Timeout for domain shutdown and boot.
connection_timeout = 5 # Timeout on the socket before attempting to connect.
logging.debug("Shutting down domain '{0}'".format(domain.name()))
- 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 fix_invalid_cce
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def fix_invalid_cce(file_contents, yaml_contents):
section = 'identifiers'
invalid_identifiers = []
- 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 gather_profiles_from_datastream
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def gather_profiles_from_datastream(path, build_dir, profiles_per_benchmark):
input_tree = ssg.xml.ElementTree.parse(path)
benchmarks = ssg.xccdf.get_benchmark_id_title_map(input_tree)
if len(benchmarks) == 0:
raise RuntimeError(
- 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 _handle_parts
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def _handle_parts(
self,
control: TypeWithParts,
) -> None:
"""Handle parts of a control."""
- 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 map_symbolic_permissions
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def map_symbolic_permissions(filemode, allow_stricter_permissions):
mode_int = int(filemode, 8)
fields = [
('o', 'x'), ('o', 'w'), ('o', 'r'),
('g', 'x'), ('g', 'w'), ('g', 'r'),
- 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 compare_ocils
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def compare_ocils(self, old_ocil_doc, old_ocil_id, new_ocil_doc, new_ocil_id, identifier):
Function walk_rules_parallel
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def walk_rules_parallel(args, left_rules, right_rules, oval_func, remediation_func):
Function find_remediation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find_remediation(
Function load_resolve_and_validate_profiles
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def load_resolve_and_validate_profiles(
Function build_index
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_index(benchmarks, input_basename, index_links, index_options,
Function render_policy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_policy(
Function handle_rule_yaml
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def handle_rule_yaml(product, rule_id, rule_dir, guide_dir, env_yaml):