ComplianceAsCode/content

View on GitHub
utils/fix_rules.py

Summary

Maintainability
F
1 wk
Test Coverage

File fix_rules.py has 544 lines of code (exceeds 400 allowed). Consider refactoring.
Open

#!/usr/bin/python3

from __future__ import print_function

import sys
Severity: Major
Found in utils/fix_rules.py - About 5 hrs to fix

    Function find_section_lines has a Cognitive Complexity of 16 (exceeds 7 allowed). Consider refactoring.
    Open

    def find_section_lines(file_contents, sec):
        # Hack to find a global key ("section"/sec) in a YAML-like file.
        # All indented lines until the next global key are included in the range.
        # For example:
        #
    Severity: Minor
    Found in utils/fix_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 remove_section_keys has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
    Open

    def remove_section_keys(file_contents, yaml_contents, section, removed_keys):
        # Remove a series of keys from a section. Refuses to operate if there is more
        # than one instance of the section. If the section is empty (because all keys
        # are removed), then the section is also removed. Otherwise, only matching keys
        # are removed. Note that all instances of the keys will be removed, if it appears
    Severity: Minor
    Found in utils/fix_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 _add_cce has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
    Open

    def _add_cce(directory, cce_pool, rules, product_yaml, args):
        product = product_yaml["product"]
    
        def is_relevant_rule(rule_path, rule, rule_lines):
            for r in rules:
    Severity: Minor
    Found in utils/fix_rules.py - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function 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 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 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

    Avoid deeply nested control flow statements.
    Open

                        if len(file_contents[line_num]) > 0 and file_contents[line_num][0] != ' ':
                            break
                        line_num += 1
    Severity: Major
    Found in utils/fix_rules.py - About 45 mins to fix

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

      def _add_cce(directory, cce_pool, rules, product_yaml, args):
      Severity: Minor
      Found in utils/fix_rules.py - About 35 mins to fix

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

        def rewrite_section_value(file_contents, yaml_contents, section, keys, transform):
        Severity: Minor
        Found in utils/fix_rules.py - About 35 mins to fix

          Function has_empty_identifier has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

          def has_empty_identifier(rule_path, rule, rule_lines):
              if 'identifiers' in rule and rule['identifiers'] is None:
                  return True
          
              if 'identifiers' in rule and rule['identifiers'] is not None:
          Severity: Minor
          Found in utils/fix_rules.py - About 25 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

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

          def find_section_lines(file_contents, sec):
          Severity: Critical
          Found in utils/fix_rules.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 cce.is_cce_value_valid("CCE-" + str(i_value)):
          Severity: Major
          Found in utils/fix_rules.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 cce.is_cce_value_valid("CCE-" + str(i_value)):
          Severity: Major
          Found in utils/fix_rules.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 file_contents[line_num][0:sec_len] == sec_id:
          Severity: Major
          Found in utils/fix_rules.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:
              # ...
          

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          @command("int_identifiers", "check and fix rules with pseudo-integer identifiers")
          def find_int_identifiers(args, product_yaml):
              results = find_rules(args, has_int_identifier)
              print("Number of rules with integer identifiers: %d" % len(results))
          
          
          Severity: Major
          Found in utils/fix_rules.py and 4 other locations - About 7 hrs to fix
          utils/fix_rules.py on lines 607..622
          utils/fix_rules.py on lines 643..657
          utils/fix_rules.py on lines 678..693
          utils/fix_rules.py on lines 707..722

          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 120.

          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

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          @command("empty_references", "check and fix rules with empty references")
          def fix_empty_references(args, product_yaml):
              results = find_rules(args, has_empty_references)
              print("Number of rules with empty references: %d" % len(results))
          
          
          Severity: Major
          Found in utils/fix_rules.py and 4 other locations - About 7 hrs to fix
          utils/fix_rules.py on lines 643..657
          utils/fix_rules.py on lines 660..675
          utils/fix_rules.py on lines 678..693
          utils/fix_rules.py on lines 707..722

          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 120.

          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

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          @command("int_references", "check and fix rules with pseudo-integer references")
          def find_int_references(args, product_yaml):
              results = find_rules(args, has_int_reference)
              print("Number of rules with integer references: %d" % len(results))
          
          
          Severity: Major
          Found in utils/fix_rules.py and 4 other locations - About 7 hrs to fix
          utils/fix_rules.py on lines 607..622
          utils/fix_rules.py on lines 643..657
          utils/fix_rules.py on lines 660..675
          utils/fix_rules.py on lines 707..722

          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 120.

          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

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          @command("sort_subkeys", "sort references and identifiers")
          def sort_subkeys(args, product_yaml):
              results = find_rules(args, has_unordered_sections)
              print("Number of modified rules: %d" % len(results))
          
          
          Severity: Major
          Found in utils/fix_rules.py and 4 other locations - About 7 hrs to fix
          utils/fix_rules.py on lines 607..622
          utils/fix_rules.py on lines 643..657
          utils/fix_rules.py on lines 660..675
          utils/fix_rules.py on lines 678..693

          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 120.

          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

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

          @command("invalid_identifiers", "check and fix rules with invalid identifiers")
          def find_invalid_cce(args, product_yamls):
              results = find_rules(args, has_invalid_cce)
              print("Number of rules with invalid CCEs: %d" % len(results))
          
          
          Severity: Major
          Found in utils/fix_rules.py and 4 other locations - About 7 hrs to fix
          utils/fix_rules.py on lines 607..622
          utils/fix_rules.py on lines 660..675
          utils/fix_rules.py on lines 678..693
          utils/fix_rules.py on lines 707..722

          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 120.

          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

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

          def has_empty_identifier(rule_path, rule, rule_lines):
              if 'identifiers' in rule and rule['identifiers'] is None:
                  return True
          
              if 'identifiers' in rule and rule['identifiers'] is not None:
          Severity: Major
          Found in utils/fix_rules.py and 1 other location - About 6 hrs to fix
          utils/fix_rules.py on lines 60..68

          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 108.

          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

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

          def has_empty_references(rule_path, rule, rule_lines):
              if 'references' in rule and rule['references'] is None:
                  return True
          
              if 'references' in rule and rule['references'] is not None:
          Severity: Major
          Found in utils/fix_rules.py and 1 other location - About 6 hrs to fix
          utils/fix_rules.py on lines 36..44

          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 108.

          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

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

          def fix_empty_identifier(file_contents, yaml_contents):
              section = 'identifiers'
          
              empty_identifiers = []
              if yaml_contents[section] is not None:
          Severity: Major
          Found in utils/fix_rules.py and 1 other location - About 5 hrs to fix
          utils/fix_rules.py on lines 380..390

          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 89.

          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

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

          def fix_empty_reference(file_contents, yaml_contents):
              section = 'references'
          
              empty_identifiers = []
          
          
          Severity: Major
          Found in utils/fix_rules.py and 1 other location - About 5 hrs to fix
          utils/fix_rules.py on lines 368..377

          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 89.

          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

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

          def has_int_identifier(rule_path, rule, rule_lines):
              if 'identifiers' in rule and rule['identifiers'] is not None:
                  for _, value in rule['identifiers'].items():
                      if type(value) != str:
                          return True
          Severity: Major
          Found in utils/fix_rules.py and 1 other location - About 4 hrs to fix
          utils/fix_rules.py on lines 99..104

          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 74.

          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

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

          def has_int_reference(rule_path, rule, rule_lines):
              if 'references' in rule and rule['references'] is not None:
                  for _, value in rule['references'].items():
                      if type(value) != str:
                          return True
          Severity: Major
          Found in utils/fix_rules.py and 1 other location - About 4 hrs to fix
          utils/fix_rules.py on lines 91..96

          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 74.

          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

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

          def fix_int_identifier(file_contents, yaml_contents):
              section = 'identifiers'
          
              int_identifiers = []
              for i_type, i_value in yaml_contents[section].items():
          Severity: Major
          Found in utils/fix_rules.py and 1 other location - About 3 hrs to fix
          utils/fix_rules.py on lines 467..475

          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 69.

          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

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

          def fix_int_reference(file_contents, yaml_contents):
              section = 'references'
          
              int_identifiers = []
              for i_type, i_value in yaml_contents[section].items():
          Severity: Major
          Found in utils/fix_rules.py and 1 other location - About 3 hrs to fix
          utils/fix_rules.py on lines 456..464

          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 69.

          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

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

                  try:
                      changes = fix_file(rule_path, product_yaml, fix_callback)
                  except RuntimeError as exc:
                      msg = (
                          "Error adding CCE into {rule_path}: {exc}"
          Severity: Major
          Found in utils/fix_rules.py and 4 other locations - About 35 mins to fix
          ssg/build_yaml.py on lines 348..351
          ssg/entities/common.py on lines 243..249
          ssg/jinja.py on lines 55..60
          utils/fix_rules.py on lines 489..493

          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 33.

          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

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

              try:
                  new_file_contents = func(file_contents, yaml_contents)
              except Exception as exc:
                  msg = "Refusing to fix file: {path}: {error}".format(path=path, error=str(exc))
                  raise RuntimeError(msg)
          Severity: Major
          Found in utils/fix_rules.py and 4 other locations - About 35 mins to fix
          ssg/build_yaml.py on lines 348..351
          ssg/entities/common.py on lines 243..249
          ssg/jinja.py on lines 55..60
          utils/fix_rules.py on lines 573..579

          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 33.

          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 (100 > 99 characters)
          Open

              new_contents[sec_ranges[0][0]] = "{section}: {content}".format(section=section, content=content)
          Severity: Minor
          Found in utils/fix_rules.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.

          There are no issues that match your filters.

          Category
          Status