Showing 111 of 113 total issues

Avoid deeply nested control flow statements.
Open

                    if arg.get("optional", False) and arg.get("multiple", False) is False:
                        args_summary += "?"
                        if arg["type"] in ["NSArg"]:
                            text = f'Zero or one namespace argument of following type(s): {", ".join([val for val in arg["values"]])}'
                        elif arg["type"] == "StrArgNSArg":
Severity: Major
Found in bel/belspec/enhance.py - About 45 mins to fix

    Function get_term_completions has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_term_completions(
    Severity: Minor
    Found in bel/api/endpoints/terms.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if arg["type"] in ["Function", "Modifier"]:
                              opt_args.extend(arg.get("values", []))
                          elif arg["type"] in ["StrArgNSArg", "NSArg", "StrArg"]:
                              opt_args.append(arg["type"])
      
      
      Severity: Major
      Found in bel/belspec/enhance.py - About 45 mins to fix

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

        def ordered_pairs(left: List[int], right: List[int]) -> List[Union[int, None]]:
            """Return ordered pairs such that every left, right pair has left < right"""
        
            alt = {"left": "right", "right": "left"}
        
        
        Severity: Minor
        Found in bel/lang/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

        Avoid deeply nested control flow statements.
        Open

                            if arg.get("optional", False) and arg.get("multiple", False) is False:
                                args_summary += "?"
                                text = f'Zero or one of each function(s): {", ".join([val for val in arg["values"]])}'
                            elif arg.get("optional", False):
                                args_summary += "*"
        Severity: Major
        Found in bel/belspec/enhance.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if not assertion.get("relation") in counts["assertions"]["relations"]:
                                  counts["assertions"]["relations"][assertion.get("relation")] = 1
                              else:
                                  counts["assertions"]["relations"][assertion.get("relation")] += 1
          
          
          Severity: Major
          Found in bel/cli/scripts.py - About 45 mins to fix

            Function get_term_completions has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def get_term_completions(
            Severity: Minor
            Found in bel/terms/terms.py - About 45 mins to fix

              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(
              Severity: Minor
              Found in bel/lang/ast.py - About 45 mins to fix

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

                    def subcomponents(self, subcomponents=None):
                        """Generate subcomponents of the BEL subject or object
                
                        Args:
                            AST
                Severity: Minor
                Found in bel/lang/ast.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 load_resource has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def load_resource(resource_url: str = None, force: bool = False):
                    """Load BEL Resource file
                
                    Forceupdate will create a new index in Elasticsearch regardless of whether
                    an index with the resource version already exists.
                Severity: Minor
                Found in bel/resources/manage.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 re.match("\s*\(", assertion["object"]):
                                        counts["assertions"]["nested"] += 1
                
                
                Severity: Major
                Found in bel/cli/scripts.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if arg["type"] in ["Function", "Modifier"]:
                                          mult_args.extend(arg.get("values", []))
                                      elif arg["type"] in ["NSArg"]:
                                          # Complex and Composite signature has this
                                          mult_args.extend(arg.get("values", []))
                  Severity: Major
                  Found in bel/belspec/enhance.py - About 45 mins to fix

                    Function get_term_search has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def get_term_search(search_term, size, entity_types, annotation_types, species, namespaces):
                    Severity: Minor
                    Found in bel/terms/terms.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if arg["type"] in ["Function", "Modifier"]:
                                              pos_args.append(arg.get("values", []))
                                          elif arg["type"] in ["StrArgNSArg", "NSArg", "StrArg"]:
                                              pos_args.append(arg["type"])
                      
                      
                      Severity: Major
                      Found in bel/belspec/enhance.py - About 45 mins to fix

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

                        def set_single_line(lines):
                        
                            flag = False
                            hold = ""
                        
                        
                        Severity: Minor
                        Found in bel/nanopub/belscripts.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 arg["type"] in ["Function", "Modifier"]:
                                                req_args.append(arg.get("values", []))
                                            elif arg["type"] in ["StrArgNSArg", "NSArg", "StrArg"]:
                                                req_args.append(arg["type"])
                        
                        
                        Severity: Major
                        Found in bel/belspec/enhance.py - About 45 mins to fix

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

                              def collect_orthologs(self, species_keys: List[Key] = settings.BEL_ORTHOLOGIZE_TARGETS):
                                  """Get orthologs for BelEntity is orthologizable"""
                          
                                  self.add_entity_types()
                                  self.normalize()
                          Severity: Minor
                          Found in bel/schemas/bel.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

                          Consider simplifying this complex logical expression.
                          Open

                                  if fn_arg.type == "Function" and fn_arg.name not in opt_and_mult_args:
                                      errors.append(
                                          ValidationError(
                                              type="Assertion",
                                              severity="Error",
                          Severity: Major
                          Found in bel/lang/ast.py - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if self.subject or self.relation or self.object:
                                        if self.relation and not self.object:
                                            msg = "Missing Assertion Object"
                                            self.errors.append(ValidationError(type="Assertion", severity="Error", msg=msg))
                                        elif self.object and (not self.subject or not self.relation):
                            Severity: Major
                            Found in bel/lang/ast.py - About 40 mins to fix

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

                                  def __init__(
                              Severity: Minor
                              Found in bel/schemas/bel.py - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language