robphoenix/diffios

View on GitHub

Showing 12 of 12 total issues

File compare.py has 315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
File: compare.py
Author: Rob Phoenix
Severity: Minor
Found in diffios/compare.py - About 3 hrs to fix

    Function _hash_lookup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def _hash_lookup(self, baseline, comparison):
            missing, additional, with_vars = [], [], []
            while not baseline.empty():
                baseline_group = baseline.get()
                baseline_parent = baseline_group[0]
    Severity: Minor
    Found in diffios/compare.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

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

            if isinstance(self._comparison, diffios.Config):
                self.comparison = self._comparison
            else:
                self.comparison = diffios.Config(self._comparison,
                                                 self._ignore_lines)
    Severity: Major
    Found in diffios/compare.py and 1 other location - About 1 hr to fix
    diffios/compare.py on lines 113..116

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

    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

            if isinstance(self._baseline, diffios.Config):
                self.baseline = self._baseline
            else:
                self.baseline = diffios.Config(self._baseline, self._ignore_lines)
    Severity: Major
    Found in diffios/compare.py and 1 other location - About 1 hr to fix
    diffios/compare.py on lines 117..121

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

    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 _with_vars_search has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _with_vars_search(self, with_vars, comparison, missing, additional):
            while with_vars:
                target = with_vars.pop()
                target_parent = target[0]
                target_children = sorted(target[1:])
    Severity: Minor
    Found in diffios/compare.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

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

                for metacharacter in diffios.REGEX_METACHARACTERS:
                    if metacharacter in line_to_ignore:
                        line_to_ignore = line_to_ignore.replace(
                            metacharacter, '\{}'.format(metacharacter))
    Severity: Minor
    Found in diffios/config.py and 1 other location - About 50 mins to fix
    diffios/compare.py on lines 127..130

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

    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

            for metacharacter in diffios.REGEX_METACHARACTERS:
                if metacharacter in target:
                    target = target.replace(metacharacter,
                                            '\{}'.format(metacharacter))
    Severity: Minor
    Found in diffios/compare.py and 1 other location - About 50 mins to fix
    diffios/config.py on lines 141..144

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

    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 _ignore_line has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _ignore_line(self, line):
            for line_to_ignore in self.ignore_lines:
                for metacharacter in diffios.REGEX_METACHARACTERS:
                    if metacharacter in line_to_ignore:
                        line_to_ignore = line_to_ignore.replace(
    Severity: Minor
    Found in diffios/config.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 _child_lookup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def _child_lookup(baseline_parent, baseline_children, comparison_children):
            ChildComparison = namedtuple('ChildComparison', 'additional missing')
            missing = []
            for baseline_child in baseline_children:
                if baseline_child not in comparison_children and not missing:
    Severity: Minor
    Found in diffios/compare.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 _binary_search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def _binary_search(self, target, search_array):
            if not search_array:
                return None
            sorted_array = sorted(search_array)
            low = 0
    Severity: Minor
    Found in diffios/compare.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 _group_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _group_config(self):
            current_group, groups = [], []
            for line in self._valid_config():
                if not line.startswith(' ') and current_group:
                    groups.append(current_group)
    Severity: Minor
    Found in diffios/config.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, baseline, comparison, ignore_lines=None):
            """Initialize a diffios.Compare object with a baseline,
                a comparison and lines to ignore.
    
            Args:
    Severity: Minor
    Found in diffios/compare.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