giganticode/codeprep

View on GitHub
codeprep/api/text.py

Summary

Maintainability
C
1 day
Test Coverage

File text.py has 368 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-FileCopyrightText: 2020 Hlib Babii <hlibbabii@gmail.com>
#
# SPDX-License-Identifier: Apache-2.0

from pathlib import Path
Severity: Minor
Found in codeprep/api/text.py - About 4 hrs to fix

    Function basic has 13 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def basic(text: str, extension: Optional[str] = None,
    Severity: Major
    Found in codeprep/api/text.py - About 1 hr to fix

      Function bpe has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def bpe(text: str, bpe_codes_id: str, extension: Optional[str] = None, no_spaces: bool = False,
      Severity: Major
      Found in codeprep/api/text.py - About 1 hr to fix

        Function nosplit has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def nosplit(text: str, extension: Optional[str] = None, no_spaces: bool = False, no_unicode: bool = False,
        Severity: Major
        Found in codeprep/api/text.py - About 1 hr to fix

          Function chars has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def chars(text: str, extension: Optional[str] = None, no_spaces: bool = False, no_unicode: bool = False,
          Severity: Major
          Found in codeprep/api/text.py - About 1 hr to fix

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

            def preprocess(text: str, config: PrepConfig, bpe_codes_id: Optional[str] = None, extension: Optional[str] = None,
            Severity: Major
            Found in codeprep/api/text.py - About 50 mins to fix

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

              def preprocess(text: str, config: PrepConfig, bpe_codes_id: Optional[str] = None, extension: Optional[str] = None,
                             force_reinit_bpe_data: bool = True, append_eof: bool = False, path: Optional[Path] = None) \
                      -> Union[TokenSequence, Tuple[TokenSequence, SnippetStructure]]:
                  parsed = [parsed_token for parsed_token in convert_text(text, extension)]
                  parsed = remove_trailing_newline(parsed)
              Severity: Minor
              Found in codeprep/api/text.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

              There are no issues that match your filters.

              Category
              Status