techno-express/mailreader

View on GitHub
decode/MailReader.php

Summary

Maintainability
B
5 hrs
Test Coverage

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

    public function findDirectory($startingDirectory = null, $directoryNamed = 'mailPiped')
    {
        $home = (\getenv('USERPROFILE') !== false) ? \getenv('USERPROFILE') : \getenv('HOME');
        $info = ($home !== false) ? $home : \dirname(__FILE__);
        $findConfigPath = $info . \DIRECTORY_SEPARATOR;
Severity: Minor
Found in decode/MailReader.php - 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

Method saveToDb has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function saveToDb()
    {
        $insert = $this->pdo->prepare("INSERT INTO emails (user, toaddr, sender, fromaddr, date, subject, plain, html) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");

        // Replace non UTF-8 characters with their UTF-8 equivalent, or drop them
Severity: Minor
Found in decode/MailReader.php - About 1 hr to fix

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

        private function saveToDb()
        {
            $insert = $this->pdo->prepare("INSERT INTO emails (user, toaddr, sender, fromaddr, date, subject, plain, html) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
    
            // Replace non UTF-8 characters with their UTF-8 equivalent, or drop them
    Severity: Minor
    Found in decode/MailReader.php - 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 getMessages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getMessages(string $email, int $offset = 0, int $max = 20)
        {
            $dbc = $this->pdo;
            if ($dbc instanceof \PDO) {
                $emails = $dbc->prepare("SELECT * FROM emails WHERE toaddr=:mail LIMIT :offset, :max");
    Severity: Minor
    Found in decode/MailReader.php - 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 getMessageAttachments has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getMessageAttachments(int $message_id)
        {
            $dbc = $this->pdo;
            if ($dbc instanceof \PDO) {
                $files = $dbc->prepare("SELECT * FROM files WHERE email=:id");
    Severity: Minor
    Found in decode/MailReader.php - 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

    There are no issues that match your filters.

    Category
    Status