BjornFJohansson/pydna

View on GitHub

Showing 140 of 219 total issues

File genbankfixer.py has 377 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2013-2023 by Björn Johansson.  All rights reserved.
# This code is part of the pydna distribution and governed by its
# license.  Please see the LICENSE.txt file that should have been included
Severity: Minor
Found in src/pydna/genbankfixer.py - About 5 hrs to fix

    Function guess_alphabet has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def guess_alphabet(sequence):
        """
        guess_alphabet(sequence)
    
        returns an apropriate Biopython alphabet based on the content of the sequence.
    Severity: Minor
    Found in scripts/guess_alphabet.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 embl_gb_fasta has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def embl_gb_fasta(text, ds, path=None):
    
        chunks = extract_from_text(text)
        result_list = []
    
    
    Severity: Minor
    Found in src/pydna/parsers.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 assemble_linear has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def assemble_linear(self, start=None, end=None, max_nodes=None):
            G = _nx.MultiDiGraph(self.G)
    
            G.add_nodes_from(["begin", "begin_rc", "end", "end_rc"], length=0)
    
    
    Severity: Minor
    Found in src/pydna/assembly.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 ligate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def ligate(fragments: list):
        """docstring."""
        G = _nx.DiGraph()
        G.add_nodes_from(["begin", "end"])
        fragments = fragments[:]
    Severity: Minor
    Found in src/pydna/ligate.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 primer_design has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def primer_design(template, fp=None, rp=None, limit=13, target_tm=55.0, tm_func=_tm_default, **kwargs):
        """This function designs a forward primer and a reverse primer for PCR amplification
        of a given template sequence.
    
        The template argument is a Dseqrecord object or equivalent containing the template sequence.
    Severity: Minor
    Found in src/pydna/design.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 run has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def run(
            self,
            till_len=0.75,  # percent of gel_len
            till_time=None,  # hours
            exposure=0.5,  # [0-1]
    Severity: Major
    Found in scripts/gel/gel_old.py - About 3 hrs to fix

      Function fuse_by_pcr has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      def fuse_by_pcr(fragments, limit=15):
          """docstring."""
      
          def anneal(x, y, limit=limit):
              """docstring."""
      Severity: Minor
      Found in src/pydna/fusionpcr.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 __repr__ has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def __repr__(self):
              """Returns a representation of the sequence, truncated if
              longer than 30 bp"""
      
              if len(self) > Dseq.trunc:
      Severity: Minor
      Found in src/pydna/dseq.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 tm_default has 27 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def tm_default(
      Severity: Major
      Found in src/pydna/tm.py - About 3 hrs to fix

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

            def products(self):
                if self._products:
                    return self._products
        
                self._products = []
        Severity: Minor
        Found in src/pydna/amplify.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 gel has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        def gel(samples=None, gel_length=600, margin=50, interpolator=interpolator(mwstd=_mwstd)):
            import numpy as np
            from PIL import Image as Image
            from PIL import ImageDraw as ImageDraw
        
        
        Severity: Minor
        Found in src/pydna/gel.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 assembly_fragments has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        def assembly_fragments(f, overlap=35, maxlink=40):
            """This function return a list of :mod:`pydna.amplicon.Amplicon` objects where
            primers have been modified with tails so that the fragments can be fused in
            the order they appear in the list by for example Gibson assembly or homologous
            recombination.
        Severity: Minor
        Found in src/pydna/design.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 all_simple_paths_edges has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

        def all_simple_paths_edges(G, source, target, cutoff=None, data=False):
            if data == True:
                edge_data = lambda u, v, n, E, I: (u, v, dict([E[n][I[n]]]))
            else:
                edge_data = lambda u, v, n, E, I: (u, v)
        Severity: Minor
        Found in scripts/_simple_paths8.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 run has 22 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def run(
        Severity: Major
        Found in scripts/gel/gel2.py - About 2 hrs to fix

          Function toGB has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          def toGB(jseq):
              "parses json jseq data and prints out ApE compatible genbank"
          
              # construct the LOCUS header string
              #  LOCUS format:
          Severity: Minor
          Found in src/pydna/genbankfixer.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 SmallestRotation has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def SmallestRotation(s):
              """Find the rotation of s that is smallest in lexicographic order.
              Duval 1983 describes how to modify his algorithm to do so but I think
              it's cleaner and more general to work from the ChenFoxLyndon output."""
          
          
          Severity: Minor
          Found in scripts/LongestCommonSubstring/experiments.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 all_circular_paths_edges has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def all_circular_paths_edges(G):
              for path in sorted(_nx.simple_cycles(G), key=len, reverse=True):
                  edges = list(zip(path, path[1:] + [path[0]]))
                  N = []
                  for u, v in edges:
          Severity: Minor
          Found in scripts/_simple_paths8.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 cutsite_is_valid has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def cutsite_is_valid(self, cutsite):
                  """Returns False if:
                  - Cut positions fall outside the sequence (could be moved to Biopython)
                  - Overhang is not double stranded
                  - Recognition site is not double stranded or is outside the sequence
          Severity: Minor
          Found in src/pydna/dseq.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 add_feature has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_feature(self, x=None, y=None, seq=None, type_="misc", strand=1, *args, **kwargs):
                  """Add a feature of type misc to the feature list of the sequence.
          
                  Parameters
                  ----------
          Severity: Minor
          Found in src/pydna/seqrecord.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

          Severity
          Category
          Status
          Source
          Language