knipknap/exscript

View on GitHub
Exscript/util/mail.py

Summary

Maintainability
C
1 day
Test Coverage

File mail.py has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#
# Copyright (C) 2010-2017 Samuel Abels
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining
Severity: Minor
Found in Exscript/util/mail.py - About 5 hrs to fix

    Mail has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Mail(object):
    
        """
        Represents an email.
        """
    Severity: Minor
    Found in Exscript/util/mail.py - About 2 hrs to fix

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

          def set_from_template_string(self, string):
              """
              Reads the given template (SMTP formatted) and sets all fields
              accordingly.
      
      
      Severity: Minor
      Found in Exscript/util/mail.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,
      Severity: Minor
      Found in Exscript/util/mail.py - About 45 mins to fix

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

        def _get_mime_object(filename):
            # Guess the content type based on the file's extension.  Encoding
            # is ignored, although we should check for simple things like
            # gzip'd or compressed files.
            ctype, encoding = mimetypes.guess_type(filename)
        Severity: Minor
        Found in Exscript/util/mail.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