KarrLab/wc_kb

View on GitHub

Showing 94 of 94 total issues

Function get_direction has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def get_direction(self):
        """ Returns the direction of the polymer feature defind by its strand and start/end coordinate

            Returns:
                :obj:`PolymerDirection`: direction (in ['forward', 'reverse'])
Severity: Minor
Found in wc_kb/core.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 serialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def serialize(self, participants, encoded=None):
        """ Serialize related object

        Args:
            participants (:obj:`list` of :obj:`SpeciesCoefficient`): Python representation of reaction participants
Severity: Minor
Found in wc_kb/core.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

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

        if args.dest_core or args.dest_seq:
            io.Writer().run(args.dest_core,
                            kb,
                            seq_path=args.dest_seq,
                            taxon=args.taxon,
Severity: Major
Found in wc_kb/__main__.py and 1 other location - About 1 hr to fix
wc_kb/__main__.py on lines 152..165

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

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

        dna_seq = self.transcript.gene.polymer.get_subseq(
                    start=ordered_cds[0].start, end=ordered_cds[-1].end)
Severity: Major
Found in wc_kb/eukaryote.py and 1 other location - About 1 hr to fix
wc_kb/eukaryote.py on lines 583..584

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

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

        dna_seq = self.transcript.gene.polymer.get_subseq(
                    start=ordered_cds[0].start, end=ordered_cds[-1].end)
Severity: Major
Found in wc_kb/eukaryote.py and 1 other location - About 1 hr to fix
wc_kb/eukaryote.py on lines 553..554

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

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

    def get_5_prime(self):
        """ Get the 5' coordinate

        Returns:
            :obj:`int`: 5' coordinate
Severity: Major
Found in wc_kb/prokaryote.py and 1 other location - About 1 hr to fix
wc_kb/prokaryote.py on lines 289..298

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

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 create_template has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def create_template(core_path, seq_path, taxon='prokaryote', write_schema=False, write_toc=True,
Severity: Major
Found in wc_kb/io.py - About 1 hr to fix

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

        def get_3_prime(self):
            """ Get the 3' coordinate
    
            Returns:
                :obj:`int`: 3' coordinate
    Severity: Major
    Found in wc_kb/prokaryote.py and 1 other location - About 1 hr to fix
    wc_kb/prokaryote.py on lines 300..309

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

    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 convert has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def convert(source_core, source_seq, dest_core, dest_seq, taxon='prokaryote', rewrite_seq_path=True, protected=True):
    Severity: Major
    Found in wc_kb/io.py - About 50 mins to fix

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

          def remove_metadata(kb):
              """ Remove metadata from Knowledge base
      
              Args:
                  kb (:obj:`wc_utils.workbook.Workbook`): knowledge base
      Severity: Minor
      Found in wc_kb/__main__.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 cell.value and isinstance(cell.value, str):
                              cell.value = '!' + cell.value
              else:
      Severity: Major
      Found in migrations/migration_2019_09_20.py - About 45 mins to fix

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

            def deserialize(self, value, objects, decoded=None):
                """ Deserialize value
                Args:
                    value (:obj:`str`): String representation
                    objects (:obj:`dict`): dictionary of objects, grouped by model
        Severity: Minor
        Found in wc_kb/core.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 cell.value and isinstance(cell.value, str):
                                cell.value = '!' + cell.value
        
        
        Severity: Major
        Found in migrations/migration_2019_09_20.py - About 45 mins to fix

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

          def transform(filename, taxon):
              # read
              wb = openpyxl.load_workbook(filename=filename)
          
              for ws in wb:
          Severity: Minor
          Found in migrations/migration_2020_04_27.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 deserialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def deserialize(self, value, objects, decoded=None):
                  """ Deserialize value
                  Args:
                      value (:obj:`str`): String representation
                      objects (:obj:`dict`): dictionary of objects, grouped by model
          Severity: Minor
          Found in wc_kb/eukaryote.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 deserialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def deserialize(cls, attribute, value, objects, compartment=None):
          Severity: Minor
          Found in wc_kb/core.py - About 35 mins to fix

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

                def calc_structure(self, ph=7.4, major_tautomer=False, keep_hydrogens=False, dearomatize=False):
            Severity: Minor
            Found in wc_kb/core.py - About 35 mins to fix

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

                  def _serialize(species, coefficient, show_compartment=True, show_coefficient_sign=True):
                      """ Serialize values
              
                      Args:
                          species (:obj:`Species`): species
              Severity: Minor
              Found in wc_kb/core.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

                      for i in adjusted_cds:
                          spliced_dna_seq += dna_seq[i[0]:i[1]]
              Severity: Minor
              Found in wc_kb/eukaryote.py and 2 other locations - About 35 mins to fix
              wc_kb/eukaryote.py on lines 434..435
              wc_kb/eukaryote.py on lines 590..591

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

                  def _append_metadata_entries(self, key, metadataObjs):
                      """ Appends wc_kb.core.Reference / wc_kb.core.DatabaseReference / wc_kb.core.Comments objects
                          to metadataObjs list
              
                          Input:
              Severity: Minor
              Found in wc_kb/core.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

              Severity
              Category
              Status
              Source
              Language