src6/Module.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid unused parameters such as '$bootstrap'.
Open

    public function init(Pluf $bootstrap): void
Severity: Minor
Found in src6/Module.php by phpmd

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 using static access to class '\Pluf_Signal' in method 'init'.
Open

        Pluf_Signal::connect('Shop_Order::stateChange', array(
            'Shop_Order_Manager_Abstract',
            'addOrderHistory'
        ));
Severity: Minor
Found in src6/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Define a constant instead of duplicating this literal "Shop_Category" 6 times.
Open

                'Shop_Category',
Severity: Critical
Found in src6/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "relate_to" 12 times.
Open

            'relate_to' => array()
Severity: Critical
Found in src6/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "Shop_Order" 5 times.
Open

        'Shop_Order' => array(
Severity: Critical
Found in src6/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "Shop_Tag" 4 times.
Open

                'Shop_Tag'
Severity: Critical
Found in src6/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "relate_to_many" 7 times.
Open

            'relate_to_many' => array(
Severity: Critical
Found in src6/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "User_Account" 6 times.
Open

                'User_Account'
Severity: Critical
Found in src6/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Class constants must be uppercase; expected RELATIONS but found relations
Open

    const relations = array(
Severity: Minor
Found in src6/Module.php by phpcodesniffer

Class constants must be uppercase; expected MODULEJSONPATH but found moduleJsonPath
Open

    const moduleJsonPath = __DIR__ . '/module.json';
Severity: Minor
Found in src6/Module.php by phpcodesniffer

Expected 1 blank line at end of file; 2 found
Open

}
Severity: Minor
Found in src6/Module.php by phpcodesniffer

Constant moduleJsonPath should be defined in uppercase
Open

    const moduleJsonPath = __DIR__ . '/module.json';
Severity: Minor
Found in src6/Module.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

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

Constant relations should be defined in uppercase
Open

    const relations = array(
        'Shop_Address' => array(
            'relate_to_many' => array(
                'User_Account'
            )
Severity: Minor
Found in src6/Module.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

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

Rename this constant "relations" to match the regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$.
Open

    const relations = array(
Severity: Critical
Found in src6/Module.php by sonar-php

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

Noncompliant Code Example

With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

define("const1", true);

class Foo {
    const const2 = "bar";
}

Compliant Solution

define("CONST1", true);

class Foo {
    const CONST2 = "bar";
}

Rename this constant "moduleJsonPath" to match the regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$.
Open

    const moduleJsonPath = __DIR__ . '/module.json';
Severity: Critical
Found in src6/Module.php by sonar-php

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all constant names match a provided regular expression.

Noncompliant Code Example

With the default regular expression ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$:

define("const1", true);

class Foo {
    const const2 = "bar";
}

Compliant Solution

define("CONST1", true);

class Foo {
    const CONST2 = "bar";
}

There are no issues that match your filters.

Category
Status