KarrLab/wc_rules

View on GitHub

Showing 74 of 74 total issues

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

dimer_binding_rule = Rule(
    name = 'dimer_binding_rule',
    reactants = {'ligand_reactant': singly_bound_ligand, 'free_receptor': free_receptor},
    actions = ['ligand_reactant.fc2.add_bond(free_receptor.alpha)'],
    rate_prefix = 'association_constant',
Severity: Minor
Found in examples/fceri_ji/submodels/naive.py and 1 other location - About 35 mins to fix
examples/fceri_ji/submodels/naive.py on lines 29..34

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 2 locations. Consider refactoring.
Open

monomer_binding_rule = Rule(
    name = 'monomer_binding_rule',
    reactants = {'ligand_reactant': free_ligand, 'free_receptor': free_receptor},
    actions = ['ligand_reactant.fc1.add_bond(free_receptor.alpha)'],
    rate_prefix = 'association_constant',
Severity: Minor
Found in examples/fceri_ji/submodels/naive.py and 1 other location - About 35 mins to fix
examples/fceri_ji/submodels/naive.py on lines 51..56

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

Function cyclic_form has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def cyclic_form(self,simple=False):
        values, orbits = list(self.sources), []
        while values:
            orb = [values.pop(0)]
            while values:
Severity: Minor
Found in wc_rules/graph/permutations.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self,action_execs,factories):
        self.execs = action_execs

        for e in self.execs:
            for fnametuple in e.deps.function_calls:
Severity: Minor
Found in wc_rules/expressions/executable.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 partition_until_edge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def partition_until_edge(labeling,group,examined=set(),partitions=[]):
    # input: canonically labeled graph
    # repeatedly partition with partition_canonical_form until you obtain single-edge graphs
    # output: examined set of labels (hashed versions), successive partitions of the graph
    CL1, CL2 = partition_canonical_form(labeling,group)
Severity: Minor
Found in wc_rules/graph/graph_partitioning.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 generate_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_actions(self):
        for g,n in self.items:
            for _ in range(n):
                for act in g.generate_actions():
                    yield act
Severity: Minor
Found in wc_rules/graph/collections.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 iter_rules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def iter_rules(self,prefix=''):
        for n,m in self.iter_models(prefix):
            if hasattr(m,'rules'):
                for n1,r1 in m.iter_rules(prefix=n):
                    yield n1,r1
Severity: Minor
Found in wc_rules/modeling/model.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 required_parameters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def required_parameters(self):
        params = []
        for x in self.rules:
            for p in x.params:
                if p not in params:
Severity: Minor
Found in wc_rules/modeling/model.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 iter_models has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def iter_models(self,prefix=''):
        for m in self.models:
            n = add_prefix(prefix,m.name) 
            yield n,m 
            if hasattr(m,'iter_models'):
Severity: Minor
Found in wc_rules/modeling/model.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 sort_by_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def sort_by_value(_dict):
    values = collections.Counter(_dict.values()).keys()
    leaders = collections.defaultdict(list)
    for v in values:
        for k,x in _dict.items():
Severity: Minor
Found in wc_rules/utils/collections.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 exec has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def exec(self,match,*dicts):
        for c in self.execs:
            actions = c.exec(match,*dicts)
            if hasattr(c,'build_variable'):
                assert isinstance(actions[-1],CollectReferences)
Severity: Minor
Found in wc_rules/expressions/executable.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 iter_edges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def iter_edges(self):
        visited = set()
        for idx,node in self.iter_nodes():
            for attr,node2 in node.iter_edges():
                edge = Edge.create(idx,attr,node2.id,node.get_related_name(attr))
Severity: Minor
Found in wc_rules/graph/collections.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 update_orbindex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def update_orbindex(orbindex,gen):
    for cyc in gen.cyclic_form():
        if len(cyc)>1:
            nums = [orbindex[x] for x in cyc]
            keys = [x for x in orbindex if orbindex[x] in nums]
Severity: Minor
Found in wc_rules/graph/canonical_labeling.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 last_occurrence has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def last_occurrence(self,node):
        if node in self:
            for i,x in reversed(list(enumerate(self._tour))):
                if x==node:
                    return i
Severity: Minor
Found in wc_rules/graph/euler_tour.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