ComplianceAsCode/content

View on GitHub
utils/create_scap_delta_tailoring.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function get_platform_rules has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
Open

def get_platform_rules(product, json_path, resolved_rules_dir, build_root):
    platform_rules = list()
    if resolved_rules_dir:
        rules_path = os.path.join(build_root, product, 'rules')
        for file in os.listdir(rules_path):
Severity: Minor
Found in utils/create_scap_delta_tailoring.py - About 1 hr to fix

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)

Severity: Minor
Found in utils/create_scap_delta_tailoring.py - About 55 mins to fix

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 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def get_implemented_stigs(product, root_path, build_config_yaml_path,
Severity: Major
Found in utils/create_scap_delta_tailoring.py - About 50 mins to fix

    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)
    Severity: Minor
    Found in utils/create_scap_delta_tailoring.py - About 45 mins to fix

    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_rule_yaml has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def handle_rule_yaml(product, rule_id, rule_dir, guide_dir, env_yaml):
    Severity: Minor
    Found in utils/create_scap_delta_tailoring.py - About 35 mins to fix

      There are no issues that match your filters.

      Category
      Status