ComplianceAsCode/content

View on GitHub

Showing 229 of 962 total issues

Function main has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
Open

def main():
    overall_result = True
    args = parse_args()
    if args.datastream is not None:
        build_dir = os.path.dirname(args.datastream)
Severity: Minor
Found in tests/run_scapval.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 print_result_differences has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
Open

def print_result_differences(json_results):
    results = [json.load(open(fname, "r")) for fname in json_results]
    rules = [common.RuleResult(r) for r in sum(results, [])]
    aggregated_results = aggregate_results_by_scenarios(rules)

Severity: Minor
Found in tests/analyze_results.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 process_results has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
Open

def process_results(result_path):
    ret_val = True
    tree = ET.parse(result_path)
    root = tree.getroot()
    results = root.find("./{%s}results" % scapval_results_ns)
Severity: Minor
Found in tests/run_scapval.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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in tests/ssg_test_suite/oscap.py - About 1 hr to fix

    Function parse_stats_subcommand has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def parse_stats_subcommand(subparsers):
        parser_stats = subparsers.add_parser(
            "stats",
            description=(
                "Obtains and displays XCCDF profile statistics. Namely number of rules in the profile,"
    Severity: Minor
    Found in build-scripts/profile_tool.py - About 1 hr to fix

      Function main has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def main():
          args = _parse_args()
          base_path = args.base
          target_path = args.target
          target_sheet = get_worksheet(base_path)
      Severity: Minor
      Found in utils/srg_diff.py - About 1 hr to fix

        Function _walk_rule has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        def _walk_rule(args, rule_obj, oval_func, remediation_func, verbose_output):
            """
            Walks a single rule and updates verbose_output if visited. Returns visited
            state as a boolean.
        
        
        Severity: Minor
        Found in ssg/rule_dir_stats.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 load_sce_and_metadata_parsed has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        def load_sce_and_metadata_parsed(raw_content):
            metadata = dict()
            sce_content = []
        
            keywords = ['platform', 'check-import', 'check-export', 'complex-check']
        Severity: Minor
        Found in ssg/build_sce.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 build has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

            def build(self, profile_id=None, rule_id=None):
                """
                Creates Playbooks for a specified profile.
                If profile is not given, creates playbooks for all profiles
                in the product.
        Severity: Minor
        Found in ssg/playbook_builder.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 validate_references has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

            def validate_references(self, yaml_file):
                if self.references is None:
                    raise ValueError("Empty references section in file %s" % yaml_file)
        
                for ref_type, ref_val in self.references.items():
        Severity: Minor
        Found in ssg/build_yaml.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 load_entities has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

            def load_entities(self, rules_by_id, values_by_id, groups_by_id):
                for rid, val in self.rules.items():
                    if not val:
                        self.rules[rid] = rules_by_id[rid]
        
        
        Severity: Minor
        Found in ssg/build_yaml.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 __lt__ has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

            def __lt__(self, other):
                comparator = Expression.__lt__(self, other)
                if comparator is not NotImplemented:
                    return comparator
        
        
        Severity: Minor
        Found in ssg/ext/boolean/boolean.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 machine_platform_missing_in_rules has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        def machine_platform_missing_in_rules(ds_path, short_ids_to_check):
            machine_platform_missing = False
            tree = ET.parse(ds_path)
            root = tree.getroot()
            only_rules_query = ".//{%s}Rule" % ssg.constants.XCCDF12_NS
        Severity: Minor
        Found in tests/test_machine_only_rules.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_viable_profiles has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        def get_viable_profiles(selected_profiles, datastream, benchmark, script=None):
            """Read data stream, and return set intersection of profiles of given
            benchmark and those provided in `selected_profiles` parameter.
            """
        
        
        Severity: Minor
        Found in tests/ssg_test_suite/rule.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 validate_playbook has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
        Open

        def validate_playbook(playbook, args):
            assert "name" in playbook, "playbook doesn't have a name"
            assert "hosts" in playbook, "playbook doesn't have the hosts entry"
            assert playbook["hosts"] == "@@HOSTS@@", "playbook's hosts is not set to @@HOSTS@@"
            assert "become" in playbook, "playbook doesn't have a become key"
        Severity: Minor
        Found in tests/assert_ansible_schema.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 from_control_dict has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def from_control_dict(cls, control_dict, env_yaml=None, default_level=["default"]):
                cls._check_keys(control_dict)
                control = cls()
                control.id = ssg.utils.required_key(control_dict, "id")
                control.title = control_dict.get("title")
        Severity: Minor
        Found in ssg/controls.py - About 1 hr to fix

          Function move_patches_up_to_date_to_source_data_stream_component has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def move_patches_up_to_date_to_source_data_stream_component(datastreamtree):
              ds_checklists = datastreamtree.find(
                  ".//{%s}checklists" % datastream_namespace)
              checklists_component_ref = ds_checklists.find(
                  "{%s}component-ref" % datastream_namespace)
          Severity: Minor
          Found in build-scripts/compose_ds.py - About 1 hr to fix

            Function reference_check has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def reference_check(env_yaml, rule_dirs, profile_path, product, product_yaml, reference,
            Severity: Major
            Found in utils/refchecker.py - About 1 hr to fix

              Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, TRUE_class=None, FALSE_class=None, Symbol_class=None, Function_class=None,
              Severity: Major
              Found in ssg/ext/boolean/boolean.py - About 1 hr to fix

                Function handle_control has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def handle_control(product: str, control: ssg.controls.Control, env_yaml: ssg.environment,
                Severity: Major
                Found in utils/create_srg_export.py - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language