iLoveTux/unitils

View on GitHub

Showing 14 of 25 total issues

Function grep has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

def grep(expr,
         files,
         line_numbers=False,
         filenames=False,
         color=False,
Severity: Minor
Found in unitils/grep.py - About 5 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 cli.py has 351 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import print_function, unicode_literals
from __future__ import print_function
import os
import sys
import unitils
Severity: Minor
Found in unitils/cli.py - About 4 hrs to fix

    Function ls has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def ls(argv=None, out=sys.stdout, err=sys.stderr):
        argv = sys.argv[1:] if argv is None else argv
        parser = argparse.ArgumentParser(
            prog="ls.py",
            description="A Simplified ls-like utility",
    Severity: Minor
    Found in unitils/cli.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 find has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def find(path=".", name=None, iname=None, ftype="*"):
        """Search for files in a directory heirarchy.
    
        This is dramatically different from the GNU version of
        find. There is no Domain Specific language.
    Severity: Minor
    Found in unitils/find.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 _gather_output has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _gather_output(counts,
                      lines,
                      byte_count,
                      chars,
                      words,
    Severity: Minor
    Found in unitils/wc.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 head has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def head(argv=None, out=sys.stdout, err=sys.stderr):
        argv = sys.argv[1:] if argv is None else argv
        parser = argparse.ArgumentParser(
            prog="head.py",
            description="A Simplified head-like utility",
    Severity: Minor
    Found in unitils/cli.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 page has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def page(text):
        """Page through text on a terminal. Similar to more.
    
        :param text: The text to page through
        :type text: str
    Severity: Minor
    Found in unitils/util.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 grep has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def grep(expr,
    Severity: Major
    Found in unitils/grep.py - About 50 mins to fix

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

      def which(cmd, _all=False):
          """Search the PATH for the first occurance of cmd.
      
          :param cmd: The command for which to search
          :param _all: If True, all occurances of cmd on the PATH will be returned
      Severity: Minor
      Found in unitils/which.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 wc has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def wc(files,
      Severity: Minor
      Found in unitils/wc.py - About 45 mins to fix

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

        def head(files, lines=10, verbose=False, quiet=False):
            """Read the first 10 lines (by default) of each file in files.
        
            As this is supposed to imitate the behavior of head, but also
            be used as a Python callable, some liberties have been taken
        Severity: Minor
        Found in unitils/head.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 _gather_output has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def _gather_output(counts,
        Severity: Minor
        Found in unitils/wc.py - About 45 mins to fix

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

          def system_call(
          Severity: Minor
          Found in unitils/util.py - About 35 mins to fix

            Function cat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def cat(files, number=False):
                """iterate through each file in files and yield each line in turn.
            
                :param files: The files to concatenate
                :param number: If True, yield two-tuples of (line_number, line)
            Severity: Minor
            Found in unitils/cat.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

            Severity
            Category
            Status
            Source
            Language