NatLibFi/Annif

View on GitHub

Showing 34 of 71 total issues

File cli.py has 659 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 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 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_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 __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_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 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_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 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def run_suggest(
                Severity: Major
                Found in annif/cli.py - About 50 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 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 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 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 __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 run_optimize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def run_optimize(project_id, paths, jobs, docs_limit, backend_param):
                        Severity: Minor
                        Found in annif/cli.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

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

                                def _update_subject_index(self, subject_corpus: SubjectCorpus) -> SubjectIndex:
                                    old_subjects = self.subjects
                                    new_subjects = annif.corpus.SubjectIndex()
                                    new_subjects.load_subjects(subject_corpus)
                                    updated_subjects = annif.corpus.SubjectIndex()
                            Severity: Minor
                            Found in annif/vocab.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

                            Severity
                            Category
                            Status
                            Source
                            Language