KarrLab/wc_rules

View on GitHub

Showing 74 of 74 total issues

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

    def function_call(self,args):
        d,s = dict(args), ''
        if 'function_name' in d and 'args' not in d:
            d['args'] = ''
        keys = sorted(d.keys())
Severity: Minor
Found in wc_rules/expressions/parse.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_node_variable has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def add_node_variable(self,name,default_value=None,executable=None,parameters={},caches={},subtype=None):
Severity: Minor
Found in wc_rules/matcher/add_methods.py - About 45 mins to fix

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

            if type(node) not in [int,float,str]:
                assert len(node.get_nonempty_related_attributes())==0
    Severity: Minor
    Found in wc_rules/graph/euler_tour.py and 1 other location - About 45 mins to fix
    wc_rules/graph/euler_tour.py on lines 158..159

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

        def attach_actions(self):
            self.attach_removenode_method()
            for attr,value in self.__class__.Meta.local_attributes.items():
                if attr == 'id':
                    continue
    Severity: Minor
    Found in wc_rules/schema/actions.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 getattr(term,'data','')=='multiply':
                            insert_this.append(Tree(data='divide',children=[]))
                        elif getattr(term,'data','')=='divide':
                            insert_this.append(Tree(data='multiply',children=[]))
                        else:
    Severity: Major
    Found in wc_rules/expressions/parse.py - About 45 mins to fix

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

          def pprint(self,nodes=None,channels=None):
              s = []
              if nodes is None:
                  nodes = self.get_nodes()
              if channels is None:
      Severity: Minor
      Found in wc_rules/matcher/print_methods.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

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

              if type(node) not in [int,float,str]:
                  assert len(node.get_nonempty_related_attributes())==0
      Severity: Minor
      Found in wc_rules/graph/euler_tour.py and 1 other location - About 45 mins to fix
      wc_rules/graph/euler_tour.py on lines 166..167

      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

      Avoid deeply nested control flow statements.
      Open

                          if getattr(term,'data','')=='add':
                              insert_this.append(Tree(data='subtract',children=[]))
                          elif getattr(term,'data','')=='subtract':
                              insert_this.append(Tree(data='add',children=[]))
                          else:
      Severity: Major
      Found in wc_rules/expressions/parse.py - About 45 mins to fix

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

            def duplicate(self,varmap={},include=None):
                if include is None:
                    include = self.keys()
        
                newnodes = dict()
        Severity: Minor
        Found in wc_rules/graph/collections.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 collect_dependencies has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def collect_dependencies(self,deps):
                if not isinstance(deps,list):
                    deps = [deps]
                while len(deps)>0:
                    x = deps.pop(0)
        Severity: Minor
        Found in wc_rules/expressions/dependency.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self,keywords,builtins,fn,code,deps):
        Severity: Minor
        Found in wc_rules/expressions/executable.py - About 35 mins to fix

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

              def add_node_pattern(self,pattern,cache=None,subtype='default',executables=[],caches={}):
          Severity: Minor
          Found in wc_rules/matcher/add_methods.py - About 35 mins to fix

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

            def check_numeric_value(value,attr,_class,_min=None,_max=None):
            Severity: Minor
            Found in wc_rules/schema/attributes.py - About 35 mins to fix

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

                  def add_channel_transform(self,source,target,datamap,actionmap,filter_data=lambda data: True):
              Severity: Minor
              Found in wc_rules/matcher/add_methods.py - About 35 mins to fix

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

                def visualize_node(node,idx,label,size=20,font={'size':20,'face':'arial'}):
                Severity: Minor
                Found in wc_rules/graph/vis.py - About 35 mins to fix

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

                  constitutive_model = BindingModel(
                      name = 'constitutive',
                      reactants = {
                          'rLyn':            free_lyn,
                          'rReceptor':    free_beta_u,
                  Severity: Minor
                  Found in examples/fceri_ji/submodels/LynReceptorBinding.py and 2 other locations - About 35 mins to fix
                  examples/fceri_ji/submodels/LynReceptorBinding.py on lines 29..39
                  examples/fceri_ji/submodels/SykReceptorBinding.py on lines 12..22

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

                      def orbits(self):
                          orbindex = index_dict(self.generators[0].sources)
                          for g in self.generators:
                              for cyc in g.cyclic_form():
                                  if len(cyc) > 1:
                  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

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

                  model = BindingModel(
                      name = 'syk_receptor',
                      reactants = {
                          'rSyk':         free_syk,
                          'rReceptor':     free_gamma,
                  Severity: Minor
                  Found in examples/fceri_ji/submodels/SykReceptorBinding.py and 2 other locations - About 35 mins to fix
                  examples/fceri_ji/submodels/LynReceptorBinding.py on lines 15..25
                  examples/fceri_ji/submodels/LynReceptorBinding.py on lines 29..39

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

                  def visualize_graph_container(g,asdict=False):
                      nodes,edges = [],[]
                      for idx,node in g.iter_nodes():
                          classname = node.__class__.__name__
                          size = 20
                  Severity: Minor
                  Found in wc_rules/graph/vis.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

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

                  active_model = BindingModel(
                      name = 'active',
                      reactants = {
                          'rLyn':            free_lyn,
                          'rReceptor':    free_beta_p,
                  Severity: Minor
                  Found in examples/fceri_ji/submodels/LynReceptorBinding.py and 2 other locations - About 35 mins to fix
                  examples/fceri_ji/submodels/LynReceptorBinding.py on lines 15..25
                  examples/fceri_ji/submodels/SykReceptorBinding.py on lines 12..22

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language