NatLibFi/Annif

View on GitHub

Showing 36 of 74 total issues

File cli.py has 710 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Definitions for command-line (Click) commands for invoking Annif
operations and printing the results to console."""

import collections
import importlib
Severity: Major
Found in annif/cli.py - About 1 day to fix

    File mllm.py has 292 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """MLLM (Maui-like Lexical Matchin) model for Annif"""
    
    from __future__ import annotations
    
    import collections
    Severity: Minor
    Found in annif/lexical/mllm.py - About 3 hrs to fix

      File hfh_util.py has 288 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Utility functions for interactions with Hugging Face Hub."""
      
      import binascii
      import configparser
      import importlib
      Severity: Minor
      Found in annif/hfh_util.py - About 2 hrs to fix

        File project.py has 280 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Project management functionality for Annif"""
        
        from __future__ import annotations
        
        import enum
        Severity: Minor
        Found in annif/project.py - About 2 hrs to fix

          AnnifProject has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class AnnifProject(DatadirMixin):
              """Class representing the configuration of a single Annif project."""
          
              # defaults for uninitialized instances
              _transform = None
          Severity: Minor
          Found in annif/project.py - About 2 hrs to fix

            Function run_detect_language has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            def run_detect_language(languages, paths):
                """
                Detect the language of a single text document from standard input or for one or more
                document file(s) given its/their path(s).
                """
            Severity: Minor
            Found in annif/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 run_eval has 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def run_eval(
            Severity: Major
            Found in annif/cli.py - About 1 hr to fix

              Function filter_suggestion has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              def filter_suggestion(
                  preds: csr_array,
                  limit: int | None = None,
                  threshold: float = 0.0,
              ) -> csr_array:
              Severity: Minor
              Found in annif/suggestion.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 run_optimize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              def run_optimize(project_id, paths, jobs, docs_limit, backend_param):
                  """
                  Suggest subjects for documents, testing multiple limits and thresholds.
                  \f
                  This command will use different limit (maximum number of subjects) and
              Severity: Minor
              Found in annif/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 __iter__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __iter__(self) -> Iterator[tuple[str, str] | tuple[str, None]]:
                      """Iterate through the directory, yielding tuples of (docfile,
                      subjectfile) containing file paths. If require_subjects is False, the
                      subjectfile will be returned as None."""
              
              
              Severity: Minor
              Found in annif/corpus/document.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 run_index has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def run_index(
              Severity: Major
              Found in annif/cli.py - About 1 hr to fix

                Function run_eval has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                def run_eval(
                    project_id,
                    paths,
                    limit,
                    threshold,
                Severity: Minor
                Found in annif/cli.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 run_suggest has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def run_suggest(
                Severity: Major
                Found in annif/cli.py - About 50 mins to fix

                  Function run_hyperopt has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def run_hyperopt(project_id, paths, docs_limit, trials, jobs, metric, results_file):
                  Severity: Major
                  Found in annif/cli.py - About 50 mins to fix

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

                    def run_suggest(
                        project_id, paths, limit, threshold, language, backend_param, docs_limit
                    ):
                        """
                        Suggest subjects for a single document from standard input or for one or more
                    Severity: Minor
                    Found in annif/cli.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 run_train has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def run_train(project_id, paths, cached, docs_limit, jobs, backend_param):
                    Severity: Minor
                    Found in annif/cli.py - About 45 mins to fix

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

                          def _find_subj_tsets(self, tset: TokenSet) -> dict[int | None, TokenSet]:
                              """return a dict (subject_id : TokenSet) of matches contained in the
                              given TokenSet"""
                      
                              subj_tsets = {}
                      Severity: Minor
                      Found in annif/lexical/tokenset.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__(
                      Severity: Minor
                      Found in annif/parallel.py - About 35 mins to fix

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

                            def hyperopt(
                        Severity: Minor
                        Found in annif/project.py - About 35 mins to fix

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

                              def prepare_train(
                          Severity: Minor
                          Found in annif/lexical/mllm.py - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language