ComplianceAsCode/content

View on GitHub
utils/add_kubernetes_rule.py

Summary

Maintainability
D
1 day
Test Coverage

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

Cyclomatic complexity is too high in function createPlatformRuleFunc. (17)
Open

@needs_oc
def createPlatformRuleFunc(args):
    url = args.url
    retries = 0
    namespace_flag = ''
Severity: Minor
Found in utils/add_kubernetes_rule.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Cyclomatic complexity is too high in function clusterTestFunc. (15)
Open

@needs_oc
@needs_working_cluster
def clusterTestFunc(args):

    print('* Testing rule %s in-cluster' % args.rule)
Severity: Minor
Found in utils/add_kubernetes_rule.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Function clusterTestFunc has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
Open

def clusterTestFunc(args):

    print('* Testing rule %s in-cluster' % args.rule)

    findout = subprocess.getoutput(
Severity: Minor
Found in utils/add_kubernetes_rule.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 add_kubernetes_rule.py has 412 lines of code (exceeds 400 allowed). Consider refactoring.
Open

#!/usr/bin/python3

import argparse
import subprocess
import sys
Severity: Minor
Found in utils/add_kubernetes_rule.py - About 2 hrs to fix

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

    def main():
        parser = argparse.ArgumentParser(
            prog="add_kubernetes_rule.py",
            formatter_class=argparse.RawDescriptionHelpFormatter,
            description=textwrap.dedent(PROG_DESC))
    Severity: Minor
    Found in utils/add_kubernetes_rule.py - About 1 hr to fix

      Function which has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
      Open

      def which(program):
          fpath, fname = os.path.split(program)
          if fpath:
              if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
                  return program
      Severity: Minor
      Found in utils/add_kubernetes_rule.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

      Avoid too many return statements within this function.
      Open

          return 0
      Severity: Major
      Found in utils/add_kubernetes_rule.py - About 30 mins to fix

        Refactor this function to reduce its Cognitive Complexity from 26 to the 15 allowed.
        Open

        def createPlatformRuleFunc(args):
        Severity: Critical
        Found in utils/add_kubernetes_rule.py by sonar-python

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed.
        Open

        def clusterTestFunc(args):
        Severity: Critical
        Found in utils/add_kubernetes_rule.py by sonar-python

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Merge this if statement with the enclosing one.
        Open

                if not os.path.isdir(group_path):
        Severity: Major
        Found in utils/add_kubernetes_rule.py by sonar-python

        Merging collapsible if statements increases the code's readability.

        Noncompliant Code Example

        if condition1:
            if condition2:
                # ...
        

        Compliant Solution

        if condition1 and condition2:
            # ...
        

        Merge this if statement with the enclosing one.
        Open

                if not os.path.isdir(group_path):
        Severity: Major
        Found in utils/add_kubernetes_rule.py by sonar-python

        Merging collapsible if statements increases the code's readability.

        Noncompliant Code Example

        if condition1:
            if condition2:
                # ...
        

        Compliant Solution

        if condition1 and condition2:
            # ...
        

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            if args.group:
                if not os.path.isdir(group_path):
                    print("ERROR: The specified group '%s' doesn't exist in the '%s' directory" % (
                        args.group, OCP_RULE_DIR))
                    return 0
        Severity: Major
        Found in utils/add_kubernetes_rule.py and 1 other location - About 1 hr to fix
        utils/add_kubernetes_rule.py on lines 206..210

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            if args.group:
                if not os.path.isdir(group_path):
                    print("ERROR: The specified group '%s' doesn't exist in the '%s' directory" % (
                        args.group, OCP_RULE_DIR))
                    return 0
        Severity: Major
        Found in utils/add_kubernetes_rule.py and 1 other location - About 1 hr to fix
        utils/add_kubernetes_rule.py on lines 240..244

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Line too long (101 > 99 characters)
        Open

            # yuumasato: The Jinja syntax is not compatible with YAML as curly braces are special characters.
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (131 > 99 characters)
        Open

                yaml_contents = yaml.dump(rule_yaml, None, indent=4, sort_keys=False, canonical=False, default_flow_style=False, width=120)
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (116 > 99 characters)
        Open

                    input=TEST_SCAN_TEMPLATE.format(PROFILE=profile, TYPE=args.scantype, NAMESPACE=args.namespace).encode())
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (137 > 99 characters)
        Open

        creating check for "/apis/config.openshift.io/v1/proxies/cluster" with yamlpath ".spec.trustedCA.name" satisfying match of "[a-zA-Z0-9]*"
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (188 > 99 characters)
        Open

        OSCAP_CMD_TEMPLATE = 'oscap xccdf eval --verbose %s --fetch-remote-resources --profile xccdf_org.ssgproject.content_profile_test --results-arf /tmp/report-arf.xml /content/ssg-ocp4-ds.xml'
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (121 > 99 characters)
        Open

                rule_yaml['warnings'] = [{'general': JinjaString('{{{ openshift_cluster_setting("%s") | indent(4) }}}' % (url))}]
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (149 > 99 characters)
        Open

                    'oc get -n {NAMESPACE} compliancescans/test -o template="{{{{.status.phase}}}} {{{{.status.result}}}}"'.format(NAMESPACE=args.namespace))
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (108 > 99 characters)
        Open

                '--match-entity', help='the entity_check value to apply, i.e., "all", "at least one", "none exist"')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (134 > 99 characters)
        Open

                '--negate', default=False, action="store_true", help='negate the given matching criteria (does NOT match). Default is false.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (105 > 99 characters)
        Open

            node_parser = type_parser.add_parser('node', help='Creates a Node rule',  parents=[common_rule_args])
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Expected 2 blank lines, found 1
        Open

        def jinja_string_representer(dumper, data):
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Line too long (105 > 99 characters)
        Open

                '--jqfilter', default="", help='A JQ filter to select the data passed down for OVAL evaluation.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (164 > 99 characters)
        Open

                '--namespace', help='Namespace where compliance operator is installed. Default is "openshift-compliance".', dest="namespace", default="openshift-compliance"
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Expected 2 blank lines, found 1
        Open

        def set_check_existence_value(value, template_vars):
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Line too long (127 > 99 characters)
        Open

                '--skip-build', default=False, action="store_true", help='Skip building and pushing the data stream. Default is true.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (123 > 99 characters)
        Open

                'test', help='Test a rule locally against a directory of mocked object files using podman and an oscap container.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Expected 2 blank lines, found 1
        Open

        class JinjaString(str):
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Line too long (100 > 99 characters)
        Open

            # A the moment this is restricted to macro calls, but could be expanded to conditionals as well.
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Expected 2 blank lines, found 1
        Open

        def set_entity_value(value, template_vars):
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Line too long (109 > 99 characters)
        Open

          contentImage: image-registry.openshift-image-registry.svc:5000/openshift-compliance/openscap-ocp4-ds:latest
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (103 > 99 characters)
        Open

                                     help='The path to a directory structure of yaml objects to test against.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (136 > 99 characters)
        Open

                '--variable', help='A string name of the XCCDF variable to with the value to check for. Mutually exclusive with "match" option')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Expected 2 blank lines after class or function definition, found 1
        Open

        yaml.add_representer(JinjaString, jinja_string_representer)
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Expected 2 blank lines after class or function definition, found 1
        Open

        PROFILE_TEMPLATE = ('''documentation_complete: true
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Line too long (112 > 99 characters)
        Open

            type_parser = create_parser.add_subparsers(dest='rule types', title='Creates a rule', help='Types of rules')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (125 > 99 characters)
        Open

                '--match', help='A string value or regex providing the matching criteria. One of "match" or "variable" are required')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (117 > 99 characters)
        Open

            platform_parser = type_parser.add_parser('platform', help='Creates a Platform rule',  parents=[common_rule_args])
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Continuation line under-indented for visual indent
        Open

                                       help='The yaml-path of the element to match against.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Continuation lines indentation.

        Continuation lines should align wrapped elements either vertically
        using Python's implicit line joining inside parentheses, brackets
        and braces, or using a hanging indent.
        
        When using a hanging indent these considerations should be applied:
        - there should be no arguments on the first line, and
        - further indentation should be used to clearly distinguish itself
          as a continuation line.
        
        Okay: a = (\n)
        E123: a = (\n    )
        
        Okay: a = (\n    42)
        E121: a = (\n   42)
        E122: a = (\n42)
        E123: a = (\n    42\n    )
        E124: a = (24,\n     42\n)
        E125: if (\n    b):\n    pass
        E126: a = (\n        42)
        E127: a = (24,\n      42)
        E128: a = (24,\n    42)
        E129: if (a or\n    b):\n    pass
        E131: a = (\n    42\n 24)

        Line too long (134 > 99 characters)
        Open

                '--url', help='The direct api path (metadata.selfLink) of the object, which overrides --type --name and --namespace options.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (121 > 99 characters)
        Open

                '--namespace', help='The namespace of the Kubernetes object (optional for cluster-scoped objects)', default=None)
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Expected 2 blank lines, found 1
        Open

        def set_template_vars(value, template_vars):
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Expected 2 blank lines, found 1
        Open

        def which(program):
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        Line too long (125 > 99 characters)
        Open

                print('there was a problem finding the URL from the oc debug output. Hint: override this automatic check with --url')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (136 > 99 characters)
        Open

            pod_cmd = 'podman run -it --security-opt label=disable -v "%s:/content" -v "%s:/kubernetes-api-resources" %s %s' % (args.contentdir,
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (103 > 99 characters)
        Open

                '--contentdir', default="./build", help='The path to the directory containing the data stream')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (133 > 99 characters)
        Open

                '--all-namespaces', action="store_true", help='The namespace of the Kubernetes object (optional for cluster-scoped objects)',
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (169 > 99 characters)
        Open

                                                                                                                                args.objectdir, OSCAP_TEST_IMAGE, oscap_cmd_opts)
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (130 > 99 characters)
        Open

                '--skip-deploy', default=False, action="store_true", help='Skip deploying the compliance-operator. Default is to deploy.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (153 > 99 characters)
        Open

                rule_yaml['warnings'] = [{'general': JinjaString("{{{ openshift_filtered_cluster_setting({'%s': '%s'}) | indent(4) }}}" % (url, args.jqfilter))}]
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (107 > 99 characters)
        Open

            # So we use an exotic token to mark where opening and closing Jinja tags would be, they are substituted
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (117 > 99 characters)
        Open

                template_vars['filepath'] = JinjaString("{{{ openshift_filtered_path('%s', '%s') }}}" % (url, args.jqfilter))
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (103 > 99 characters)
        Open

                # if previous compliancescans were actually deleted, wait a bit to allow resources to clean up.
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (116 > 99 characters)
        Open

                '--skip-build', default=False, action="store_true", help='Skip building the data stream. Default is false.')
        Severity: Minor
        Found in utils/add_kubernetes_rule.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Rename function "createPlatformRuleFunc" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
        Open

        def createPlatformRuleFunc(args):
        Severity: Major
        Found in utils/add_kubernetes_rule.py by sonar-python

        Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

        Noncompliant Code Example

        With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

        def MyFunction(a,b):
            ...
        

        Compliant Solution

        def my_function(a,b):
            ...
        

        Rename function "createNodeRuleFunc" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
        Open

        def createNodeRuleFunc(args):
        Severity: Major
        Found in utils/add_kubernetes_rule.py by sonar-python

        Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

        Noncompliant Code Example

        With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

        def MyFunction(a,b):
            ...
        

        Compliant Solution

        def my_function(a,b):
            ...
        

        Rename function "clusterTestFunc" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
        Open

        def clusterTestFunc(args):
        Severity: Major
        Found in utils/add_kubernetes_rule.py by sonar-python

        Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

        Noncompliant Code Example

        With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

        def MyFunction(a,b):
            ...
        

        Compliant Solution

        def my_function(a,b):
            ...
        

        Rename function "testFunc" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
        Open

        def testFunc(args):
        Severity: Major
        Found in utils/add_kubernetes_rule.py by sonar-python

        Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

        Noncompliant Code Example

        With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

        def MyFunction(a,b):
            ...
        

        Compliant Solution

        def my_function(a,b):
            ...
        

        Rename function "createTestProfile" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
        Open

        def createTestProfile(rule):
        Severity: Major
        Found in utils/add_kubernetes_rule.py by sonar-python

        Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

        Noncompliant Code Example

        With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

        def MyFunction(a,b):
            ...
        

        Compliant Solution

        def my_function(a,b):
            ...
        

        There are no issues that match your filters.

        Category
        Status