sebastianmonzel/webfiles-framework-php

View on GitHub
source/core/datastore/types/mail/MImapDatastore.php

Summary

Maintainability
B
4 hrs
Test Coverage
F
0%

Function mail_decode_part has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function mail_decode_part($connection, $message_number, $part, $prefix)
    {
        $attachment = array();

        if ($part->ifdparameters) {
Severity: Minor
Found in source/core/datastore/types/mail/MImapDatastore.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 getAllWebfiles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getAllWebfiles()
    {

        $webfileArray = array();
Severity: Minor
Found in source/core/datastore/types/mail/MImapDatastore.php - About 1 hr to fix

Method mail_decode_part has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function mail_decode_part($connection, $message_number, $part, $prefix)
    {
        $attachment = array();

        if ($part->ifdparameters) {
Severity: Minor
Found in source/core/datastore/types/mail/MImapDatastore.php - About 1 hr to fix

Method imap_login has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private function imap_login($host, $port, $user, $pass, $folder = "INBOX", $ssl = false)
Severity: Minor
Found in source/core/datastore/types/mail/MImapDatastore.php - About 45 mins to fix

The method mail_mime_to_array has a boolean flag argument $parse_headers, which is a certain sign of a Single Responsibility Principle violation.
Open

    private function mail_mime_to_array($imap, $mid, $parse_headers = false)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method imap_login has a boolean flag argument $ssl, which is a certain sign of a Single Responsibility Principle violation.
Open

    private function imap_login($host, $port, $user, $pass, $folder = "INBOX", $ssl = false)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Avoid unused private methods such as 'mail_get_parts'.
Open

    private function mail_get_parts($imap, $mid, $part, $prefix)
    {
        $attachments = array();
        $attachments[$prefix] = mail_decode_part($imap, $mid, $part, $prefix);
        if (isset($part->parts)) // multipart

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid unused private methods such as 'pop3_stat'.
Open

    private function pop3_stat($connection)
    {
        $check = imap_mailboxmsginfo($connection);
        return ((array)$check);
    }

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid unused private methods such as 'pop3_retr'.
Open

    private function pop3_retr($connection, $message)
    {

        return (imap_fetchheader($connection, $message, FT_PREFETCHTEXT));
    }

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid unused private methods such as 'mail_parse_headers'.
Open

    private function mail_parse_headers($headers)
    {
        $result = array();

        $headers = preg_replace('/\r\n\s+/m', '', $headers);

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid unused private methods such as 'mail_mime_to_array'.
Open

    private function mail_mime_to_array($imap, $mid, $parse_headers = false)
    {

        $mail = imap_fetchstructure($imap, $mid);
        $mail = mail_get_parts($imap, $mid, $mail, 0);

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid unused private methods such as 'mail_decode_part'.
Open

    private function mail_decode_part($connection, $message_number, $part, $prefix)
    {
        $attachment = array();

        if ($part->ifdparameters) {

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid unused parameters such as '$count'.
Open

    public function getLatestWebfiles($count = 5)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused private methods such as 'pop3_dele'.
Open

    private function pop3_dele($connection, $message)
    {

        return (imap_delete($connection, $message));
    }

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid excessively long variable names like $completeNumberOfMessages. Keep variable name length under 20.
Open

        $completeNumberOfMessages = $MC->Nmsgs;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $numberOfMessagesToShow. Keep variable name length under 20.
Open

        $numberOfMessagesToShow = 4;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

The parameter $parse_headers is not named in camelCase.
Open

    private function mail_mime_to_array($imap, $mid, $parse_headers = false)
    {

        $mail = imap_fetchstructure($imap, $mid);
        $mail = mail_get_parts($imap, $mid, $mail, 0);

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $message_number is not named in camelCase.
Open

    private function mail_decode_part($connection, $message_number, $part, $prefix)
    {
        $attachment = array();

        if ($part->ifdparameters) {

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

Avoid variables with short names like $MC. Configured minimum length is 3.
Open

        $MC = imap_check($this->connection);

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

The property $m_oMailAccount is not named in camelCase.
Open

class MImapDatastore extends MAbstractDatastore
    implements MISingleDatasourceDatastore
{

    /**@var MMailAccount **/

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The variable $parse_headers is not named in camelCase.
Open

    private function mail_mime_to_array($imap, $mid, $parse_headers = false)
    {

        $mail = imap_fetchstructure($imap, $mid);
        $mail = mail_get_parts($imap, $mid, $mail, 0);

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $message_number is not named in camelCase.
Open

    private function mail_decode_part($connection, $message_number, $part, $prefix)
    {
        $attachment = array();

        if ($part->ifdparameters) {

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $MC is not named in camelCase.
Open

    private function imap_getlist()
    {

        $result = array();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $MC is not named in camelCase.
Open

    private function imap_getlist()
    {

        $result = array();

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method imap_login is not named in camelCase.
Open

    private function imap_login($host, $port, $user, $pass, $folder = "INBOX", $ssl = false)
    {

        $ssl = ($ssl == false) ? "/novalidate-cert" : "/ssl";
        return (imap_open("{" . "$host:$port/imap4$ssl" . "}$folder", $user, $pass));

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method pop3_stat is not named in camelCase.
Open

    private function pop3_stat($connection)
    {
        $check = imap_mailboxmsginfo($connection);
        return ((array)$check);
    }

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method imap_getlist is not named in camelCase.
Open

    private function imap_getlist()
    {

        $result = array();

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method mail_decode_part is not named in camelCase.
Open

    private function mail_decode_part($connection, $message_number, $part, $prefix)
    {
        $attachment = array();

        if ($part->ifdparameters) {

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method pop3_dele is not named in camelCase.
Open

    private function pop3_dele($connection, $message)
    {

        return (imap_delete($connection, $message));
    }

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method mail_parse_headers is not named in camelCase.
Open

    private function mail_parse_headers($headers)
    {
        $result = array();

        $headers = preg_replace('/\r\n\s+/m', '', $headers);

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method pop3_retr is not named in camelCase.
Open

    private function pop3_retr($connection, $message)
    {

        return (imap_fetchheader($connection, $message, FT_PREFETCHTEXT));
    }

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method mail_get_parts is not named in camelCase.
Open

    private function mail_get_parts($imap, $mid, $part, $prefix)
    {
        $attachments = array();
        $attachments[$prefix] = mail_decode_part($imap, $mid, $part, $prefix);
        if (isset($part->parts)) // multipart

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method mail_mime_to_array is not named in camelCase.
Open

    private function mail_mime_to_array($imap, $mid, $parse_headers = false)
    {

        $mail = imap_fetchstructure($imap, $mid);
        $mail = mail_get_parts($imap, $mid, $mail, 0);

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status