Showing 229 of 962 total issues
Function get_rule_dir_ovals
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def get_rule_dir_ovals(dir_path, product=None):
"""
Gets a list of OVALs contained in a rule directory. If product is
None, returns all OVALs. If product is not None, returns applicable
OVALs 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
Function parse_from_file_with_jinja
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def parse_from_file_with_jinja(self, env_yaml, cpe_platforms):
self.local_env_yaml.update(env_yaml)
result = super(BashRemediation, self).parse_from_file_with_jinja(
self.local_env_yaml, cpe_platforms)
- 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 add_profiles_from_dir
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def add_profiles_from_dir(self, dir_, env_yaml, product_cpes):
for dir_item in sorted(os.listdir(dir_)):
dir_item_path = os.path.join(dir_, dir_item)
if not os.path.isfile(dir_item_path):
continue
- 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_implemented_stigs
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def get_implemented_stigs(product, root_path, build_config_yaml_path,
reference_str, json_path, resolved_rules_dir,
build_root):
platform_rules = get_platform_rules(product, json_path, resolved_rules_dir, 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 _ensure_by_xccdf_referenced_oval_def_is_defined_in_oval_file
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def _ensure_by_xccdf_referenced_oval_def_is_defined_in_oval_file(self):
# Ensure all OVAL checks referenced by XCCDF are implemented in OVAL file
# Drop the reference from XCCDF to OVAL definition if:
# * Particular OVAL definition isn't present in OVAL file,
# * That OVAL definition doesn't constitute a remote OVAL
- 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 _rule_matches_rule_spec
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def _rule_matches_rule_spec(self, rule_short_id):
rule_id = OSCAP_RULE + rule_short_id
if 'ALL' in self.rule_spec:
return True
else:
- 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 check_build_dir
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def check_build_dir(build_dir):
profiles_per_benchmark = defaultdict(list)
for path in glob.glob(os.path.join(build_dir, "ssg-*-ds.xml")):
gather_profiles_from_datastream(path, build_dir, profiles_per_benchmark)
- 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 _add_cce
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def _add_cce(directory, cce_pool, rules, product_yaml, args):
product = product_yaml["product"]
def is_relevant_rule(rule_path, rule, rule_lines):
for r in rules:
- 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 main
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def main():
args = parse_args()
json_file = open(args.json, 'r')
known_rules = json.load(json_file)
- 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 main
has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring. Open
def main():
args = parse_args()
json_file = open(args.json, 'r')
known_rules = json.load(json_file)
- 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 process_remediation
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_remediation(
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, env_yaml, resolved_rules_dir, templates_dir,
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, old_content, new_content, rule_id, show_diffs, rule_diffs,
Function collect_remediations
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def collect_remediations(
Function get_implemented_stigs
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_implemented_stigs(product, root_path, build_config_yaml_path,
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, old_content, new_content, rule_id, show_diffs, rule_diffs,
Function main
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def main():
options, args = parse_args()
if options.centos:
mapping = ssg.constants.RHEL_CENTOS_CPE_MAPPING
- 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 j < i:
i -= 1
continue
Function remove_cce_reference
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def remove_cce_reference(tree_root, namespace):
"""
Remove CCE identifiers from OVAL checks in XML tree
"""
for definition in tree_root.findall(".//{%s}definition" % (namespace)):
- 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 is_applicable_for_product
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
def is_applicable_for_product(platform, product):
"""Based on the platform dict specifier of the remediation script to
determine if this remediation script is applicable for this product.
Return 'True' if so, 'False' otherwise"""
- 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"