aliciawyy/dmining

View on GitHub

Showing 23 of 35 total issues

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

    def _partial_fit(self, X, y, classes=None, _refit=False,
                     sample_weight=None):

        """
        Adapt the class with the same name in scikit-learn to accept missing 
Severity: Minor
Found in models/classifiers.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 match has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def match(p1, p2):
    idx1 = idx2 = 0
    while idx1 < len(p1) and idx2 < len(p2):
        if p1[idx1] != "*" and p2[idx2] != "*":
            if p1[idx1] != p2[idx2]:
Severity: Minor
Found in puzzle/pattern_overlap.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 longest_zig_zag has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def longest_zig_zag(seq):
    """
    The complexity is n2 with DP.
    Auxiliary Space is n.
    """
Severity: Minor
Found in puzzle/dynamic_programming.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 construct_min_prices has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def construct_min_prices(self):
        zipped_info = [zip(self.info[0][j], self.info[1][j], self.info[2][j])
                       for j in range(self.n_prices)]

        def get_price_wrap(k):
Severity: Minor
Found in puzzle/booking/available.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 min_strokes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def min_strokes(self, stripes):
        self.set_stripes(stripes)
        n = len(self.stripes_)
        # n_strokes is a state matrix that shows how many moves are needed
        # from the position i to j
Severity: Minor
Found in puzzle/stripe_painter.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 longest_common_sub_sequence has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def longest_common_sub_sequence(a, b):
    """
    http://www.geeksforgeeks.org/
    dynamic-programming-set-4-longest-common-subsequence/
    """
Severity: Minor
Found in puzzle/palindrome.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 max_donation_from_neighbors has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def max_donation_from_neighbors(donations):
    # init
    dons = np.array(donations, dtype=np.int16)
    dons = np.roll(dons, -np.argmax(dons))

Severity: Minor
Found in puzzle/dynamic_programming.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 max_score_sum has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def max_score_sum(self):
        max_sum = {(self.budget, 0): 0}

        for cost, visit_time, score in self.attractions:
            new_max_sum = dict(max_sum)
Severity: Minor
Found in puzzle/booking/tripplanner.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 eval_mcc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def eval_mcc(y_true, y_prob, show=False):
    idx = np.argsort(y_prob)
    y_true = np.array(y_true, dtype=int)
    y_true_sort = y_true[idx]
    n = y_true.shape[0]
Severity: Minor
Found in models/metrics.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 print_insertion_sort has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def print_insertion_sort(arr):
    for i in range(1, len(arr)):
        num_i = arr[i]
        k = i
        for j in range(i - 1, -1, -1):
Severity: Minor
Found in puzzle/sorting.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 get_num_shift has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_num_shift(arr):
    cnt = 0
    for i in range(1, len(arr)):
        k = i
        for j in range(i - 1, -1, -1):
Severity: Minor
Found in puzzle/sorting.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 grid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def grid(self):
        if self.n == 0:
            return "IO"
        elif self.n <= self.max_num_per_line:
            return self.horizontal_pattern * self.n
Severity: Minor
Found in puzzle/word.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 print_insertion_sort2 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def print_insertion_sort2(arr):
    for i in range(1, len(arr)):
        num_i = arr[i]
        k = i
        for j in range(i - 1, -1, -1):
Severity: Minor
Found in puzzle/sorting.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 _partial_fit has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _partial_fit(self, X, y, classes=None, _refit=False,
Severity: Minor
Found in models/classifiers.py - About 35 mins to fix

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

    def update_mean_variance(n_past, mu, var, X, sample_weight=None):
    Severity: Minor
    Found in models/classifiers.py - About 35 mins to fix

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

      def shortest_palindromes(base):
          if len(base) <= 1:
              return base
          if is_palindrome(base):
              return base
      Severity: Minor
      Found in puzzle/palindrome.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 sort_merge_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def sort_merge_string(x, y):
          result = ''
          while len(x) > 0 or len(y) > 0:
              if len(x) == 0:
                  result += y
      Severity: Minor
      Found in puzzle/palindrome.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 make_sum has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def make_sum(dct_values, base=None):
          """base is some previous result"""
          sum_cnt = collections.defaultdict(int)
          if base is not None:
              sum_cnt.update(base)
      Severity: Minor
      Found in puzzle/jewelry.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 _all_star(p2[idx2:])
      Severity: Major
      Found in puzzle/pattern_overlap.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return _all_star(p1[idx1:])
        Severity: Major
        Found in puzzle/pattern_overlap.py - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language