libratom/libratom

View on GitHub

Showing 25 of 25 total issues

Function get_messages has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def get_messages(
    files: Iterable[Path],
    progress_callback: Callable,
    with_content=True,
    with_headers=False,
Severity: Minor
Found in libratom/lib/concurrency.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 extract_entities has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def extract_entities(
    files: Iterable[Path],
    session: Session,
    spacy_model: Language,
    include_message_contents: bool = False,
Severity: Minor
Found in libratom/lib/entities.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

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

# pylint: disable=unused-argument
"""
Command-line interface for libratom
"""

Severity: Minor
Found in libratom/cli/cli.py - About 2 hrs to fix

    File pff.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # pylint: disable=consider-using-ternary,attribute-defined-outside-init
    """
    PFF parsing utilities. Requires libpff.
    """
    
    
    Severity: Minor
    Found in libratom/lib/pff.py - About 2 hrs to fix

      Function get_spacy_models has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_spacy_models() -> Dict[str, List[str]]:
      
          releases = {}
      
          paginated_url = "https://api.github.com/repos/explosion/spacy-models/releases?page=1&per_page=100"
      Severity: Minor
      Found in libratom/lib/core.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 _get_mime_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_mime_type(self, attachment: pypff.attachment) -> Optional[str]:
      
              entries = attachment.record_sets[0].entries
      
              # Try known positions first
      Severity: Minor
      Found in libratom/lib/pff.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 process_message has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def process_message(
      Severity: Major
      Found in libratom/lib/entities.py - About 1 hr to fix

        Function _decode_mime_type has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _decode_mime_type(self, data: bytes) -> Optional[str]:
        
                for encoding in self._encodings:
                    try:
                        mime_type = data.decode(encoding).rstrip("\0")
        Severity: Minor
        Found in libratom/lib/pff.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 extract_entities has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def extract_entities(
        Severity: Major
        Found in libratom/lib/entities.py - About 1 hr to fix

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

              def get_attachment_metadata(
                  self, message: pypff.message
              ) -> List[AttachmentMetadata]:
                  """
                  Returns the metadata of all attachments in a given message
          Severity: Minor
          Found in libratom/lib/pff.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 load_spacy_model has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def load_spacy_model(spacy_model_name: str) -> Tuple[Optional[Language], Optional[str]]:
              """
              Loads and returns a given spaCy model
          
              If the model is not present, an attempt will be made to download and install it
          Severity: Minor
          Found in libratom/lib/core.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

          Avoid deeply nested control flow statements.
          Open

                              if name != "Name":
                                  media_types.append(f"{file.stem}/{name.split(maxsplit=1)[0]}")
          
          
          Severity: Major
          Found in libratom/scripts/get_media_type_list.py - About 45 mins to fix

            Function entities has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def entities(
            Severity: Minor
            Found in libratom/cli/subcommands.py - About 45 mins to fix

              Function entities has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def entities(out, spacy_model, include_message_contents, jobs, src, progress):
              Severity: Minor
              Found in libratom/cli/cli.py - About 45 mins to fix

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

                def generate_report(
                    files: Iterable[Path],
                    session: Session,
                    include_message_contents: bool = False,
                    progress_callback: Optional[Callable] = None,
                Severity: Minor
                Found in libratom/lib/report.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 entities has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def entities(
                    out: Path,
                    spacy_model_name: str,
                    jobs: Optional[int],
                    src: Path,
                Severity: Minor
                Found in libratom/cli/subcommands.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 report has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def report(out, include_message_contents, jobs, src, progress):
                Severity: Minor
                Found in libratom/cli/cli.py - About 35 mins to fix

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

                  def store_configuration_in_db(
                  Severity: Minor
                  Found in libratom/lib/report.py - About 35 mins to fix

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

                    def report(
                    Severity: Minor
                    Found in libratom/cli/subcommands.py - About 35 mins to fix

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

                      def get_messages(
                      Severity: Minor
                      Found in libratom/lib/concurrency.py - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language