ComplianceAsCode/content

View on GitHub

Showing 229 of 962 total issues

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 = []

Severity: Minor
Found in utils/fix_rules.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Minor
Found in utils/oscal/cd_generator.py - About 45 mins to fix

    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)):
    Severity: Minor
    Found in utils/fix_rules.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_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."""
    Severity: Minor
    Found in utils/oscal/cd_generator.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 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
    Severity: Minor
    Found in utils/fix_rules.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 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():
    Severity: Minor
    Found in utils/tables/table_renderer.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 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 = []
    
    
    Severity: Minor
    Found in utils/fix_rules.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 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(
    Severity: Minor
    Found in tests/stable_profile_ids.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 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()))
    Severity: Minor
    Found in tests/ssg_test_suite/virt.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 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'),
    Severity: Minor
    Found in shared/templates/file_permissions/template.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 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):
    Severity: Minor
    Found in ssg/content_diff.py - About 35 mins to fix

      Function _walk_rule has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _walk_rule(args, rule_obj, oval_func, remediation_func, verbose_output):
      Severity: Minor
      Found in ssg/rule_dir_stats.py - About 35 mins to fix

        Function add_cpe_item_to_dictionary has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def add_cpe_item_to_dictionary(
        Severity: Minor
        Found in ssg/build_derivatives.py - About 35 mins to fix

          Function _process_controls_manager has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def _process_controls_manager(controls_manager, env_yaml, product_yaml, profile, rule_dirs):
          Severity: Minor
          Found in utils/refchecker.py - About 35 mins to fix

            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):
            Severity: Minor
            Found in ssg/rule_dir_stats.py - About 35 mins to fix

              Function find_remediation has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def find_remediation(
              Severity: Minor
              Found in build-scripts/collect_remediations.py - About 35 mins to fix

                Function load_resolve_and_validate_profiles has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def load_resolve_and_validate_profiles(
                Severity: Minor
                Found in build-scripts/compile_all.py - About 35 mins to fix

                  Function compare_platforms has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def compare_platforms(self, old_rule, new_rule, old_benchmark, new_benchmark, identifier):
                  Severity: Minor
                  Found in ssg/content_diff.py - About 35 mins to fix

                    Function fill_queue has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def fill_queue(benchmarks, benchmark_profile_pairs, input_path, path_base,
                    Severity: Minor
                    Found in ssg/build_guides.py - About 35 mins to fix

                      Function compare_ovals has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def compare_ovals(self, old_oval_def_doc, old_oval_def_id,
                      Severity: Minor
                      Found in ssg/content_diff.py - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language