samdmarshall/pyconfig

View on GitHub

Showing 76 of 76 total issues

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

    def formatting(self):
        return {
            "0": ['underline'],
            "21": ['normal'],
            "260": ['blue'],
Severity: Minor
Found in slides/slide8.py and 1 other location - About 45 mins to fix
slides/slide19.py on lines 19..29

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

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 formatting(self):
        return {
                # project
                "0": ['underline'],
                "7": ['normal'],
Severity: Minor
Found in slides/slide19.py and 1 other location - About 45 mins to fix
slides/slide8.py on lines 17..24

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

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

Function readWhitespace has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def readWhitespace(self, content=None, index=None):
        status, index_increase, line_increase, char_number, last_newline_increase, error = readWhitespace(content, index)
        # update error message
        if error is not None: # pragma: no cover
            self.error = '%s at line: %i, index: %i' % (error, self.line_number, self.char_number)
Severity: Minor
Found in pyconfig/Analyzer/Linter.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 consume has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def consume(self, parsed_item=None):
        parsed_item = list() if parsed_item is None else parsed_item
        super(SettingKeyword, self).consume(parsed_item)

        if parsed_item[0] != Constants._setting:  # pylint: disable=protected-access
Severity: Minor
Found in pyconfig/Keyword/SettingKeyword.py - About 35 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 shouldAppendConditionItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def shouldAppendConditionItem(condition):
    result = False
    for case in Switch(condition):
        if case(''):
            break
Severity: Minor
Found in pyconfig/Deserializer/KeyValue.py - About 35 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 readQuotedString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def readQuotedString(self):
        status = True
        while status is True:
            status = self.readString('"')
            if status is False:
Severity: Minor
Found in pyconfig/Analyzer/Linter.py - About 35 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 __runInitializer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __runInitializer(self, configuration):
        """
        This method is to pass through the passed in file
        """
        self.__namespace_table[configuration.name] = dict()
Severity: Minor
Found in pyconfig/Analyzer/Engine.py - About 35 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 __gatherUserDefinedVariables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __gatherUserDefinedVariables(self):
        self.__user_defined_table = set()
        snapshot_of_dict = list(self.__namespace_table.items())
        for _configuration, values in snapshot_of_dict:
            for keyword in values.values():
Severity: Minor
Found in pyconfig/Analyzer/Engine.py - About 35 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 value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def value(self):
        value = self.__value
        if len(value) == 0:
            value = ''
        else:
Severity: Minor
Found in pyconfig/Deserializer/KeyValue.py - About 35 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 findKeyValueAssignmentOffset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def findKeyValueAssignmentOffset(cls, line, offset):
        result_offset = -1
        find_open_bracket = line.find('[')
        find_equals = line.find('=')
        new_offset = offset
Severity: Minor
Found in pyconfig/Deserializer/KeyValue.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

Function findDuplicates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def findDuplicates(dictionary):
    results = dict()
    settings_set = set()
    snapshot_of_dict = list(dictionary.items())
    for configuration, values in snapshot_of_dict:
Severity: Minor
Found in pyconfig/Analyzer/Engine.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

Function WalkNodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def WalkNodes(visited=None, nodes_with_children=None):
    visited = set() if visited is None else visited
    nodes_with_children = list() if nodes_with_children is None else nodes_with_children

    child_nodes = list()
Severity: Minor
Found in pyconfig/Graph/Grapher.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

Function openOutputFileToWrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def openOutputFileToWrite(input_string):
    """
    Takes a path to the output file as a string and returns an open
    writeable file. The path will be expanded and parent directories
    will be created if necessary.
Severity: Minor
Found in pyconfig/Serializer/Serializer.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

Function serialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def serialize(self):
        serialize_string = ''
        if self.uses_for:
            for key, value in self.configuration_values.items():
                serialize_string += self.serializeForStatement(key, value)
Severity: Minor
Found in pyconfig/Keyword/SettingKeyword.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

Function findPreviousDefinition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def findPreviousDefinition(kv_array, configuration, setting_key):
    previous_definition_indexes = list()
    for file_name, value in kv_array:
        if file_name != configuration:
            setting_values = list(value.keys())
Severity: Minor
Found in pyconfig/Analyzer/Engine.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

Function gatherAllVariables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def gatherAllVariables(dictionary):
    settings_set = set()
    snapshot_of_dict = list(dictionary.items())
    for _configuration, values in snapshot_of_dict:
        for keyword in values.values():
Severity: Minor
Found in pyconfig/Analyzer/Engine.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

Severity
Category
Status
Source
Language