lenskit/lkpy

View on GitHub

Showing 15 of 15 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    if k is not None:
        _log.debug("truncating to k for recall")
        tcounts = np.minimum(tcounts, k)
        recs = recs[recs["rank"] <= k]
Severity: Major
Found in lenskit/metrics/topn.py and 1 other location - About 2 hrs to fix
lenskit/metrics/topn.py on lines 97..100

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    if k is not None:
        _log.debug("truncating to k for recall")
        tcounts = np.minimum(tcounts, k)
        recs = recs[recs["rank"] <= k]
Severity: Major
Found in lenskit/metrics/topn.py and 1 other location - About 2 hrs to fix
lenskit/metrics/topn.py on lines 142..145

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function fit has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def fit(self, ratings, **kwargs):
        """
        Train a FunkSVD model.

        Args:
Severity: Minor
Found in lenskit/algorithms/funksvd.py - About 1 hr to fix

    Function predict_for_user has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def predict_for_user(self, user, items, ratings=None):
            _logger.debug("predicting %d items for user %s", len(items), user)
            if ratings is None:
                if user not in self.user_index_:
                    _logger.debug("user %s missing, returning empty predictions", user)
    Severity: Minor
    Found in lenskit/algorithms/item_knn.py - About 1 hr to fix

      Function fit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def fit(self, ratings, **kwargs):
              """
              Train a model.
      
              The model-training process depends on ``save_nbrs`` and ``min_sim``, but *not* on other
      Severity: Minor
      Found in lenskit/algorithms/item_knn.py - About 1 hr to fix

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

            if k is not None:
                recs = recs[recs["rank"] <= k]
        Severity: Minor
        Found in lenskit/metrics/topn.py and 2 other locations - About 35 mins to fix
        lenskit/metrics/topn.py on lines 351..352
        lenskit/metrics/topn.py on lines 429..430

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

            if k is not None:
                recs = recs[recs["rank"] <= k]
        Severity: Minor
        Found in lenskit/metrics/topn.py and 2 other locations - About 35 mins to fix
        lenskit/metrics/topn.py on lines 191..192
        lenskit/metrics/topn.py on lines 351..352

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

            if k is not None:
                recs = recs[recs["rank"] <= k]
        Severity: Minor
        Found in lenskit/metrics/topn.py and 2 other locations - About 35 mins to fix
        lenskit/metrics/topn.py on lines 191..192
        lenskit/metrics/topn.py on lines 429..430

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Avoid too many return statements within this function.
        Open

            return problems
        Severity: Major
        Found in lenskit/util/debug.py - About 30 mins to fix

          Whitespace before ':'
          Open

                  train = np.concatenate((xs[:start], xs[start + size :]))
          Severity: Minor
          Found in lenskit/crossfold.py by pep8

          Avoid extraneous whitespace.

          Avoid extraneous whitespace in these situations:
          - Immediately inside parentheses, brackets or braces.
          - Immediately before a comma, semicolon, or colon.
          
          Okay: spam(ham[1], {eggs: 2})
          E201: spam( ham[1], {eggs: 2})
          E201: spam(ham[ 1], {eggs: 2})
          E201: spam(ham[1], { eggs: 2})
          E202: spam(ham[1], {eggs: 2} )
          E202: spam(ham[1 ], {eggs: 2})
          E202: spam(ham[1], {eggs: 2 })
          
          E203: if x == 4: print x, y; x, y = y , x
          E203: if x == 4: print x, y ; x, y = y, x
          E203: if x == 4 : print x, y; x, y = y, x

          Whitespace before ':'
          Open

                  return udf.sort_values(self.column).iloc[-self.n :]
          Severity: Minor
          Found in lenskit/crossfold.py by pep8

          Avoid extraneous whitespace.

          Avoid extraneous whitespace in these situations:
          - Immediately inside parentheses, brackets or braces.
          - Immediately before a comma, semicolon, or colon.
          
          Okay: spam(ham[1], {eggs: 2})
          E201: spam( ham[1], {eggs: 2})
          E201: spam(ham[ 1], {eggs: 2})
          E201: spam(ham[1], { eggs: 2})
          E202: spam(ham[1], {eggs: 2} )
          E202: spam(ham[1 ], {eggs: 2})
          E202: spam(ham[1], {eggs: 2 })
          
          E203: if x == 4: print x, y; x, y = y , x
          E203: if x == 4: print x, y ; x, y = y, x
          E203: if x == 4 : print x, y; x, y = y, x

          Module level import not at top of file
          Open

          import lenskit
          Severity: Minor
          Found in docs/conf.py by pep8

          Place imports at the top of the file.

          Always put imports at the top of the file, just after any module
          comments and docstrings, and before module globals and constants.
          
          Okay: import os
          Okay: # this is a comment\nimport os
          Okay: '''this is a module docstring'''\nimport os
          Okay: r'''this is a module docstring'''\nimport os
          Okay:
          try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
          Okay:
          try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
          E402: a=1\nimport os
          E402: 'One string'\n"Two string"\nimport os
          E402: a=1\nfrom sys import x
          
          Okay: if x:\n    import os

          Whitespace before ':'
          Open

                  test = xs[start : start + size]
          Severity: Minor
          Found in lenskit/crossfold.py by pep8

          Avoid extraneous whitespace.

          Avoid extraneous whitespace in these situations:
          - Immediately inside parentheses, brackets or braces.
          - Immediately before a comma, semicolon, or colon.
          
          Okay: spam(ham[1], {eggs: 2})
          E201: spam( ham[1], {eggs: 2})
          E201: spam(ham[ 1], {eggs: 2})
          E201: spam(ham[1], { eggs: 2})
          E202: spam(ham[1], {eggs: 2} )
          E202: spam(ham[1 ], {eggs: 2})
          E202: spam(ham[1], {eggs: 2 })
          
          E203: if x == 4: print x, y; x, y = y , x
          E203: if x == 4: print x, y ; x, y = y, x
          E203: if x == 4 : print x, y; x, y = y, x

          Whitespace before ':'
          Open

                  trains = test_sets[:i] + test_sets[(i + 1) :]
          Severity: Minor
          Found in lenskit/crossfold.py by pep8

          Avoid extraneous whitespace.

          Avoid extraneous whitespace in these situations:
          - Immediately inside parentheses, brackets or braces.
          - Immediately before a comma, semicolon, or colon.
          
          Okay: spam(ham[1], {eggs: 2})
          E201: spam( ham[1], {eggs: 2})
          E201: spam(ham[ 1], {eggs: 2})
          E201: spam(ham[1], { eggs: 2})
          E202: spam(ham[1], {eggs: 2} )
          E202: spam(ham[1 ], {eggs: 2})
          E202: spam(ham[1], {eggs: 2 })
          
          E203: if x == 4: print x, y; x, y = y , x
          E203: if x == 4: print x, y ; x, y = y, x
          E203: if x == 4 : print x, y; x, y = y, x

          Whitespace before ':'
          Open

                      test_us = users[i * size : (i + 1) * size]
          Severity: Minor
          Found in lenskit/crossfold.py by pep8

          Avoid extraneous whitespace.

          Avoid extraneous whitespace in these situations:
          - Immediately inside parentheses, brackets or braces.
          - Immediately before a comma, semicolon, or colon.
          
          Okay: spam(ham[1], {eggs: 2})
          E201: spam( ham[1], {eggs: 2})
          E201: spam(ham[ 1], {eggs: 2})
          E201: spam(ham[1], { eggs: 2})
          E202: spam(ham[1], {eggs: 2} )
          E202: spam(ham[1 ], {eggs: 2})
          E202: spam(ham[1], {eggs: 2 })
          
          E203: if x == 4: print x, y; x, y = y , x
          E203: if x == 4: print x, y ; x, y = y, x
          E203: if x == 4 : print x, y; x, y = y, x
          Severity
          Category
          Status
          Source
          Language