ComplianceAsCode/content

View on GitHub

Showing 231 of 1,039 total issues

File templates.py has 490 lines of code (exceeds 400 allowed). Consider refactoring.
Open

"""
Common functions for processing Templates in SSG
"""

from __future__ import absolute_import
Severity: Minor
Found in ssg/templates.py - About 4 hrs to fix

    File common.py has 489 lines of code (exceeds 400 allowed). Consider refactoring.
    Open

    from __future__ import print_function
    
    import functools
    import logging
    import os
    Severity: Minor
    Found in tests/ssg_test_suite/common.py - About 4 hrs to fix

      File ansible_playbook_to_role.py has 487 lines of code (exceeds 400 allowed). Consider refactoring.
      Open

      #!/usr/bin/python3
      
      from __future__ import print_function
      
      from tempfile import mkdtemp
      Severity: Minor
      Found in utils/ansible_playbook_to_role.py - About 4 hrs to fix

        File test_env.py has 482 lines of code (exceeds 400 allowed). Consider refactoring.
        Open

        from __future__ import print_function
        
        import contextlib
        import json
        import logging
        Severity: Minor
        Found in tests/ssg_test_suite/test_env.py - About 4 hrs to fix

          File build_remediations.py has 480 lines of code (exceeds 400 allowed). Consider refactoring.
          Open

          from __future__ import absolute_import
          from __future__ import print_function
          
          import sys
          import os
          Severity: Minor
          Found in ssg/build_remediations.py - About 3 hrs to fix

            Function get_profile_stats has a Cognitive Complexity of 28 (exceeds 7 allowed). Consider refactoring.
            Open

                def get_profile_stats(self, profile):
                    """Obtain statistics for the profile"""
            
                    # Holds the intermediary statistics for profile
                    profile_stats = {
            Severity: Minor
            Found in ssg/build_profile.py - About 3 hrs 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 remove_idents has a Cognitive Complexity of 28 (exceeds 7 allowed). Consider refactoring.
            Open

            def remove_idents(tree_root, namespace, prod="RHEL"):
                """
                Remove product identifiers from rules in XML tree
                """
            
            
            Severity: Minor
            Found in ssg/build_derivatives.py - About 3 hrs 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 sort_section_keys has a Cognitive Complexity of 27 (exceeds 7 allowed). Consider refactoring.
            Open

            def sort_section_keys(file_path, file_contents, sections, sort_func=None):
                """
                Sort subkeys in a YAML file's section.
            
                Args:
            Severity: Minor
            Found in ssg/rule_yaml.py - About 3 hrs 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 translate has a Cognitive Complexity of 27 (exceeds 7 allowed). Consider refactoring.
            Open

                def translate(self, tree, store_defname=False):
                    """
                    Translates the IDs of elements in an XML tree to new identifiers.
            
                    Args:
            Severity: Minor
            Found in ssg/id_translate.py - About 3 hrs 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 createPlatformRuleFunc has a Cognitive Complexity of 26 (exceeds 7 allowed). Consider refactoring.
            Open

            def createPlatformRuleFunc(args):
                url = args.url
                retries = 0
                namespace_flag = ''
                if args.namespace is not None:
            Severity: Minor
            Found in utils/add_kubernetes_rule.py - About 3 hrs 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

            File rule_dir_stats.py has 453 lines of code (exceeds 400 allowed). Consider refactoring.
            Open

            """
            This module contains common code shared by utils/rule_dir_stats.py and utils/rule_dir_diff.py.
            This code includes functions for walking the output of the utils/rule_dir_json.py script, and
            filtering functions used in both scripts.
            """
            Severity: Minor
            Found in ssg/rule_dir_stats.py - About 3 hrs to fix

              Benchmark has 27 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Benchmark(XCCDFEntity):
                  """Represents XCCDF Benchmark
                  """
                  KEYS = dict(
                      status=lambda: "",
              Severity: Minor
              Found in ssg/build_yaml.py - About 3 hrs to fix

                RuleChecker has 27 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class RuleChecker(oscap.Checker):
                    """
                    Rule checks generally work like this -
                    for every profile that supports that rule:
                
                
                Severity: Minor
                Found in tests/ssg_test_suite/rule.py - About 3 hrs to fix

                  File constants.py has 442 lines of code (exceeds 400 allowed). Consider refactoring.
                  Open

                  from __future__ import absolute_import
                  from __future__ import print_function
                  
                  import os.path
                  import os
                  Severity: Minor
                  Found in ssg/constants.py - About 3 hrs to fix

                    Function move_patches_up_to_date_to_source_data_stream_component has a Cognitive Complexity of 23 (exceeds 7 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 2 hrs 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 walk_rules_parallel has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def walk_rules_parallel(args, left_rules, right_rules, oval_func, remediation_func):
                        """
                        Walks two sets of known_rules (left_rules and right_rules) with identical keys and returns
                        left_only, right_only, and common_only output from _walk_rule.
                    
                    
                    Severity: Minor
                    Found in ssg/rule_dir_stats.py - About 2 hrs 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 has_duplicated_subkeys has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def has_duplicated_subkeys(file_path, file_contents, sections):
                        """
                        Checks whether a section has duplicated keys in a YAML file.
                    
                        Note that these duplicated keys are silently ignored by the YAML parser used.
                    Severity: Minor
                    Found in ssg/rule_yaml.py - About 2 hrs 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 determine_ip has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def determine_ip(domain):
                        GUEST_AGENT_XML = ("<channel type='unix'>"
                                           "  <source mode='bind'/>"
                                           "  <target type='virtio'"
                                           "          name='org.qemu.guest_agent.0'"
                    Severity: Minor
                    Found in tests/ssg_test_suite/virt.py - About 2 hrs 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

                    File automatus.py has 433 lines of code (exceeds 400 allowed). Consider refactoring.
                    Open

                    #!/usr/bin/python3
                    from __future__ import print_function
                    
                    import argparse
                    import contextlib
                    Severity: Minor
                    Found in tests/automatus.py - About 2 hrs to fix

                      Function get_profile_stats has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def get_profile_stats(self, profile):
                              """Obtain statistics for the profile"""
                      
                              # Holds the intermediary statistics for profile
                              profile_stats = {
                      Severity: Major
                      Found in ssg/build_profile.py - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language