vanheeringen-lab/gimmemotifs

View on GitHub
gimmemotifs/utils.py

Summary

Maintainability
C
7 hrs
Test Coverage
D
61%

Function write_equalsize_bedfile has a Cognitive Complexity of 24 (exceeds 15 allowed). Consider refactoring.
Open

def write_equalsize_bedfile(bedfile, size, outfile):
    """Read input from <bedfile>, set the size of all entries to <size> and
    write the result to <outfile>.
    Input file needs to be in BED or WIG format."""
    if size is None or size <= 0:
Severity: Minor
Found in gimmemotifs/utils.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 determine_file_type has a Cognitive Complexity of 24 (exceeds 15 allowed). Consider refactoring.
Open

def determine_file_type(fname):
    """
    Detect file type.

    The following file types are supported:
Severity: Minor
Found in gimmemotifs/utils.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

Avoid deeply nested control flow statements.
Open

                    if warn_no_summit:
                        logger.warning(
                            "No summit present in narrowPeak file, "
                            "using the peak center."
                        )
Severity: Major
Found in gimmemotifs/utils.py - About 45 mins to fix

    Avoid too many return statements within this function.
    Open

                    return "unknown"
    Severity: Major
    Found in gimmemotifs/utils.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                          return "unknown"
      Severity: Major
      Found in gimmemotifs/utils.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                            return "narrowpeak"
        Severity: Major
        Found in gimmemotifs/utils.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return "unknown"
          Severity: Major
          Found in gimmemotifs/utils.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return "region"
            Severity: Major
            Found in gimmemotifs/utils.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return "bed"
              Severity: Major
              Found in gimmemotifs/utils.py - About 30 mins to fix

                Function pfmfile_location has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring.
                Open

                def pfmfile_location(infile=None):
                    """Return the path to the pfmfile"""
                    config = MotifConfig()
                
                    if infile is None:
                Severity: Minor
                Found in gimmemotifs/utils.py - About 25 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

                There are no issues that match your filters.

                Category
                Status