KarrLab/wc_rules

View on GitHub

Showing 49 of 74 total issues

Function simplify_tree has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

def simplify_tree(tree): 
    '''
    # PURPOSE: simplify and standardize expressions using arithmetic rules
    # Rules for simplification
    # parent ->factor -> noflip,item ==> parent -> item AKA +x ==> x
Severity: Minor
Found in wc_rules/expressions/parse.py - About 1 day 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 attach_edgeattr_methods has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def attach_edgeattr_methods(self,attr):
        def add_edge_fn(self,*args):
            targets = deque()
            for arg in args:
                if isinstance(arg,list):
Severity: Minor
Found in wc_rules/schema/actions.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

BaseClass has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class BaseClass(core.Model,ActionMixin):
    ''' Base class for building objects '''
    id = IdAttribute()

    def __init__(self, *args, **kwargs):
Severity: Minor
Found in wc_rules/schema/base.py - About 2 hrs to fix

    File actions.py has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from dataclasses import dataclass
    from collections import deque, ChainMap
    from types import MethodType
    from abc import ABC, abstractmethod
    from obj_tables import core
    Severity: Minor
    Found in wc_rules/schema/actions.py - About 2 hrs to fix

      File collections.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      :Author: John Sekar <johnarul.sekar@gmail.com>
      :Date: 2017-12-13
      :Copyright: 2017, Karr Lab
      :License: MIT
      Severity: Minor
      Found in wc_rules/utils/collections.py - About 2 hrs to fix

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

        def canonical_label(g):
        
            partition = initialize_partition(g)
            opp = ordered_partition_pair(partition,partition)
            orbindex = initialize_orbindex(partition)
        Severity: Minor
        Found in wc_rules/graph/canonical_labeling.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

        Function get_attribute_calls has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_attribute_calls(self):
                attrcalls = defaultdict(SortedSet)
                for c in self.execs:
                    for k,v in c.deps.attribute_calls.items():
                        attrcalls[k].update(v)
        Severity: Minor
        Found in wc_rules/expressions/executable.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 simulate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def simulate(self,start=0.0,end=1.0,period=1,write_location=None):
                global CURRENT_ACTION_RECORD
                print(f'Simulating from time={start} to time={end}.')
                time = start
                sch = CoordinatedScheduler([
        Severity: Minor
        Found in wc_rules/simulator/simulator.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 iter_items has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def iter_items(d,mode='tuple'):
                if mode=='tuple':
                    for k,v in d.items():
                        if isinstance(v,dict):
                            for k1,v1 in NestedDict.iter_items(v):
        Severity: Minor
        Found in wc_rules/utils/data.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 augcut has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def augcut(self,edge):
                node1,attr1,attr2,node2 = edge
                tour = self.find_edge(node1,node2)[0]
                if edge in tour._spares:
                    tour.remove_spares([edge])
        Severity: Minor
        Found in wc_rules/graph/euler_tour.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 get_helper_calls has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_helper_calls(self):
                helpercalls = defaultdict(SortedSet)
                for c in self.execs:
                    for fnametuple,kwargs in c.deps.function_calls.items():
                        if len(fnametuple)==2:
        Severity: Minor
        Found in wc_rules/expressions/executable.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 initialize_pattern has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize_pattern(self,pattern):
        
                if self.get_node(core=pattern) is not None:
                    return self
        
        
        Severity: Minor
        Found in wc_rules/matcher/initialize_methods.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 dfs_visit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def dfs_visit(tree,ignore_tokens=True):
            yield tree
            if hasattr(tree,'children'):
                for child in tree.children:
                    for elem in dfs_visit(child):
        Severity: Minor
        Found in wc_rules/expressions/exprgraph_utils.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 initialize_from_strings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize_from_strings(cls,strings,classes,cmax=0):
                d = dict()
                allowed_forms = '\n'.join([x for c in classes for x in c.allowed_forms])
                for s in strings:
                    for c in classes:
        Severity: Minor
        Found in wc_rules/expressions/executable.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 function_node_constraints has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def function_node_constraints(self,node,token):
                Logger.pattern(node.num,token)
                executable_manager = node.data.executables
                caches = node.data.caches
                if token.action == 'AddEntry':
        Severity: Minor
        Found in wc_rules/matcher/node_functions.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 process_function_call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_function_call(self,x):
                if 'function_name' in x:
                    kws, kwpairs = set(),set()
                    if 'kws' in x:
                        for kw,arg in zip(x['kws'],x['args']):
        Severity: Minor
        Found in wc_rules/expressions/dependency.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 do has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def do(self):
                global CURRENT_ACTION_RECORD
                CURRENT_ACTION_RECORD = deque()
        
                tokens = []
        Severity: Minor
        Found in wc_rules/simulator/simulator.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 duplicate_relations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def duplicate_relations(self,target,nodemap,attrlist=None):
                ''' Duplicates self's relations, converts them using nodemap {id:new_node}, and applies to targetself.
                E.g. if old A1->X1, and nodemap { A1.id:A2, X1.id:X2 }
                A1.duplicate_relations(A2,nodemap) builds the new edge A2->X2
                 '''
        Severity: Minor
        Found in wc_rules/schema/base.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 visualize_exprgraph has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def visualize_exprgraph(g,asdict=False):
            nodes,edges = [],[]
            for idx,node in g.iter_nodes():
                label = node.serialize_for_vis() if isinstance(node,ExprBase) else node.id
                nodes.append(visualize_node(node=node,idx=node.id,label=label))
        Severity: Minor
        Found in wc_rules/graph/vis.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 check_cycle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def check_cycle(gdict):
            # gdict is a directed graph represented as a dict
            # node0: [node1, node2]
            # node3: [node4]
            nodes,paths = deque(gdict), deque()
        Severity: Minor
        Found in wc_rules/utils/validate.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

        Severity
        Category
        Status
        Source
        Language