Showing 113 of 113 total issues

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

Severity: Major
Found in bel/api/core/jwt.py and 1 other location - About 2 days to fix
api/app/core/jwt.py on lines 0..69

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

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

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

Severity: Major
Found in api/app/core/jwt.py and 1 other location - About 2 days to fix
bel/api/core/jwt.py on lines 0..69

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

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

File ast.py has 1101 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-


# Standard Library
Severity: Major
Found in bel/lang/ast.py - About 2 days to fix

    Function validate_function has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_function(fn: Function, errors: List[ValidationError] = None) -> List[ValidationError]:
        """Validate function"""
    
        # logger.debug(f"Validating function name {fn.name}, len: {len(fn.args)}")
    
    
    Severity: Minor
    Found in bel/lang/ast.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 add_function_signature_help has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_function_signature_help(specification: dict) -> dict:
        """Add function signature help
    
        Simplify the function signatures for presentation to BEL Editor users
        """
    Severity: Minor
    Found in bel/belspec/enhance.py - About 7 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

    File terms.py has 458 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # Standard Library
    import re
    import time
    from typing import Any, List, Mapping, Optional, Union
    
    
    Severity: Minor
    Found in bel/terms/terms.py - About 7 hrs to fix

      Function parse has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(self):
              """Assemble parsed component from Assertion string into AST"""
      
              self.parse_info = ParseInfo(self.assertion)
      
      
      Severity: Minor
      Found in bel/lang/ast.py - About 6 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 sort_function_args has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

      def sort_function_args(fn: Function):
          """Add sort tuple values to function arguments for canonicalization and sort function arguments"""
      
          signatures = fn.function_signature["signatures"]
      
      
      Severity: Minor
      Found in bel/lang/ast.py - About 6 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 enhance_function_signatures has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

      def enhance_function_signatures(specification: Mapping[str, Any]) -> Mapping[str, Any]:
          """Enhance function signatures
      
          Add required and optional objects to signatures objects for semantic validation
          support.
      Severity: Minor
      Found in bel/belspec/enhance.py - About 6 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

      File bel.py has 386 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Standard Library
      import copy
      import enum
      import json
      import re
      Severity: Minor
      Found in bel/schemas/bel.py - About 5 hrs to fix

        File parse.py has 360 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python
        # -*- coding: utf-8 -*-
        
        # Standard Library
        import copy
        Severity: Minor
        Found in bel/lang/parse.py - About 4 hrs to fix

          Function get_term_completions has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_term_completions(
              completion_text: str,
              size: int = 10,
              entity_types: List[str] = None,
              annotation_types: List[str] = None,
          Severity: Minor
          Found in bel/terms/terms.py - About 4 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

          File validate.py has 316 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # Standard Library
          import copy
          import re
          from typing import List, Tuple
          
          
          Severity: Minor
          Found in bel/nanopub/validate.py - About 3 hrs to fix

            Function terms_iterator_for_arangodb has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

            def terms_iterator_for_arangodb(f: IO, version: str):
                """Generator for loading namespace terms into arangodb"""
            
                species_list = settings.BEL_FILTER_SPECIES
            
            
            Severity: Minor
            Found in bel/resources/namespace.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

            Function get_normalized_terms has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_normalized_terms(
                term_key: Key,
                canonical_targets: Mapping[str, List[str]] = settings.BEL_CANONICALIZE,
                decanonical_targets: Mapping[str, List[str]] = settings.BEL_DECANONICALIZE,
                term: Optional[Term] = None,
            Severity: Minor
            Found in bel/terms/terms.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

            File namespace.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # Standard Library
            import copy
            import gzip
            import json
            import time
            Severity: Minor
            Found in bel/resources/namespace.py - About 3 hrs to fix

              Function validate_annotation has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              def validate_annotation(annotation):
                  """Check elasticsearch index for annotation term"""
              
                  if not annotation.get("hash", False):
                      annotation_str = get_annotation_str(annotation)
              Severity: Minor
              Found in bel/nanopub/validate.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

              File arangodb.py has 298 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # Standard Library
              import re
              from dataclasses import dataclass
              from typing import List, Mapping, Optional
              
              
              Severity: Minor
              Found in bel/db/arangodb.py - About 3 hrs to fix

                Function get_best_match has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_best_match(query_str, belspec_versions: BelSpecVersions):
                    """Get best match to query version in versions or return latest"""
                
                    try:
                        query = semver.VersionInfo.parse(query_str)
                Severity: Minor
                Found in bel/belspec/crud.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

                Function nanopub_stats has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                def nanopub_stats(ctx, input_fn):
                    """Collect statistics on nanopub file
                
                    input_fn can be json, jsonl or yaml and additionally gzipped
                    """
                Severity: Minor
                Found in bel/cli/scripts.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

                Severity
                Category
                Status
                Source
                Language