mattwalshdev/emailee

View on GitHub
emailee/emailee.py

Summary

Maintainability
D
2 days
Test Coverage

File emailee.py has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import enum
import mimetypes
import re
import smtplib
from email.mime.application import MIMEApplication
Severity: Minor
Found in emailee/emailee.py - About 4 hrs to fix

    Function send has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def send(self, outputFile: str = "") -> bool:
            if self._authPassword and not self._authUsername and self._sender:
                # this may happen if server methods are invoked before
                #  the sender method AND the person has not added an
                #  authUsername BUT has added an authPassword
    Severity: Minor
    Found in emailee/emailee.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 server has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def server(
            self,
            smtpServer: str,
            *,
            port: int = 0,
    Severity: Minor
    Found in emailee/emailee.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

    Function _generate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def _generate(self) -> str:
            message = MIMEMultipart("mixed")
    
            message["to"] = ", ".join(self._to) if self._to else ""
    
    
    Severity: Minor
    Found in emailee/emailee.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

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

        def _addressCheck(
            self, emailList: List[str], type: str, ignoreErrors: bool
        ) -> List[str]:
            self._tempEmailList = []
            for email in emailList:
    Severity: Minor
    Found in emailee/emailee.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 _helperOutputFileCheck has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _helperOutputFileCheck(filename: str) -> bool:
        try:
            if Path(filename).is_file():
                try:
                    fileSize: int = Path(filename).stat().st_size
    Severity: Minor
    Found in emailee/emailee.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 server has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def server(
    Severity: Major
    Found in emailee/emailee.py - About 50 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if (
                  self._sender
                  and (self._to or self._cc or self._bcc)
                  and self._smtpServer
                  and self._port
      Severity: Major
      Found in emailee/emailee.py - About 40 mins to fix

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

            def sendTo(
                self,
                to: List[str] = [],
                cc: List[str] = [],
                bcc: List[str] = [],
        Severity: Minor
        Found in emailee/emailee.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

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

            def attachmentFiles(self, attachmentFiles: List[str] = []) -> None:
                if not isinstance(attachmentFiles, list):
                    raise TypeError("attachmentFiles not in list format")
        
                for file in attachmentFiles:
        Severity: Minor
        Found in emailee/emailee.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

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

            def ready(self) -> bool:
                if self._authPassword and not self._authUsername and self._sender:
                    # this may happen if server methods are invoked before
                    #  the sender method AND the person has not added an
                    #  authUsername BUT has added an authPassword
        Severity: Minor
        Found in emailee/emailee.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