sirfoga/pyhal

View on GitHub

Showing 18 of 24 total issues

Matrix has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class Matrix(BaseMatrix):
    def __init__(self, matrix):
        super().__init__(matrix)

    def shape(self):
Severity: Minor
Found in hal/maths/la/matrix.py - About 3 hrs to fix

    Function test_miller_rabin has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def test_miller_rabin(self, precision):
            """Tests prime with miller-rabin algorithm
    
            :param precision: number of rounds to perform
            :return: True iff probably prime
    Severity: Minor
    Found in hal/maths/nt/primes.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 _get_modules has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_modules(path):
        """Finds modules in folder recursively
    
        :param path: directory
        :return: list of modules
    Severity: Minor
    Found in hal/meta/attributes.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 ls_recurse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def ls_recurse(path, include_hidden=False):
        """Finds content of folder recursively
    
        :param path: directory to get list of files and folders
        :param include_hidden: True iff include hidden files in list
    Severity: Minor
    Found in hal/files/models/system.py - About 55 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 prettify has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def prettify(name, blank=" "):
        """Prettify name of path
    
        :param name: path Name: to edit
        :param blank: default blanks in name
    Severity: Minor
    Found in hal/files/models/system.py - About 55 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 i == t - 1:
                                return False
                            else:
                                i += 1
                                v = (v ** 2) % self.to_int
    Severity: Major
    Found in hal/maths/nt/primes.py - About 45 mins to fix

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

          def __eq__(self, other):
              if isinstance(other, list):
                  other = Matrix(other)
      
              if self.shape() != other.shape():
      Severity: Minor
      Found in hal/maths/la/matrix.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,
      Severity: Minor
      Found in hal/internet/email/templates.py - About 35 mins to fix

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

            def plot_type(self, func, mins, maxs, precision, kind):
        Severity: Minor
        Found in hal/charts/plotter.py - About 35 mins to fix

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

              def solve(self, table_size):
                  """Solves problem
          
                  :param table_size: Size of table
                  :return: List of possible solutions
          Severity: Minor
          Found in hal/maths/problems.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

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

              def get_number(self, question, min_i=float("-inf"), max_i=float("inf"),
                             just_these=None):
                  """Parses answer and gets number
          
                  :param question: Question: to ask user
          Severity: Minor
          Found in hal/streams/user.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

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

              def increase(self, amount=1):
                  if self.levels.head.val.increase(amount):
                      return True
          
                  # head cannot increase -> reset and check for carry
          Severity: Minor
          Found in hal/cvs/versioning.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

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

              def get_last(weekday, including_today=False):
                  """Gets last day of week
          
                  :param weekday: day of week
                  :param including_today: If today is sunday and requesting last sunday
          Severity: Minor
          Found in hal/times/dates.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

          Avoid too many return statements within this function.
          Open

                      return self.get_yes_no(self.last_question)
          Severity: Major
          Found in hal/streams/user.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return False
            Severity: Major
            Found in hal/streams/user.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return 0, 0  # stay here
              Severity: Major
              Found in hal/maths/probability/markov_chains/brownian.py - About 30 mins to fix

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

                    def check_on(self, f):
                        for row in range(self.get_n_rows()):
                            for col in range(self.get_n_cols()):
                                element = self.get_at(row, col)
                                if not f(element):
                Severity: Minor
                Found in hal/maths/la/matrix.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

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

                    def is_diagonally_dominant(self, strictly=False):
                        for i, row in enumerate(self.m):
                            diagonal_element = row[0, i]
                            sum_of_others = np.sum(row) - diagonal_element
                
                
                Severity: Minor
                Found in hal/maths/la/matrix.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