src/Shop/Shortcuts.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '125', column '15').
Open

    throw new Pluf_Exception_DoesNotExist(
Severity: Minor
Found in src/Shop/Shortcuts.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '110', column '14').
Open

    $q = new Pluf_SQL('name=%s', array(
Severity: Minor
Found in src/Shop/Shortcuts.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '99', column '15').
Open

    throw new Pluf_HTTP_Error404("Object whit given secure id not found (" . $model . ", " . $secureId . ")");
Severity: Minor
Found in src/Shop/Shortcuts.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '113', column '17').
Open

    $item = new Shop_Tag();
Severity: Minor
Found in src/Shop/Shortcuts.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid using static access to class 'Pluf_Log' in method 'Shop_Shortcuts_GetTagByNameOr404'.
Open

        Pluf_Log::error(
            sprintf('more than one tag exist with the name $s', $name));
Severity: Minor
Found in src/Shop/Shortcuts.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

Add curly braces around the nested statement(s).
Open

    if ($count > 30)
Severity: Critical
Found in src/Shop/Shortcuts.php by sonar-php

While not technically incorrect, the omission of curly braces can be misleading, and may lead to the introduction of errors during maintenance.

Noncompliant Code Example

if (condition)  // Noncompliant
  executeSomething();

Compliant Solution

if (condition) {
  executeSomething();
}

See

  • MISRA C:2004, 14.8 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
  • MISRA C:2004, 14.9 - An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
  • MISRA C++:2008, 6-3-1 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
  • MISRA C++:2008, 6-4-1 - An if (condition) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
  • MISRA C:2012, 15.6 - The body of an iteration-statement or a selection-statement shall be a compound-statement
  • CERT, EXP19-C. - Use braces for the body of an if, for, or while statement
  • CERT, EXP52-J. - Use braces for the body of an if, for, or while statement

Remove this commented out code.
Open

// {
Severity: Major
Found in src/Shop/Shortcuts.php by sonar-php

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

See

  • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
  • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
  • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
  • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

Add curly braces around the nested statement(s).
Open

    if (isset($mapper[$itemType]))
Severity: Critical
Found in src/Shop/Shortcuts.php by sonar-php

While not technically incorrect, the omission of curly braces can be misleading, and may lead to the introduction of errors during maintenance.

Noncompliant Code Example

if (condition)  // Noncompliant
  executeSomething();

Compliant Solution

if (condition) {
  executeSomething();
}

See

  • MISRA C:2004, 14.8 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
  • MISRA C:2004, 14.9 - An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
  • MISRA C++:2008, 6-3-1 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
  • MISRA C++:2008, 6-4-1 - An if (condition) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
  • MISRA C:2012, 15.6 - The body of an iteration-statement or a selection-statement shall be a compound-statement
  • CERT, EXP19-C. - Use braces for the body of an if, for, or while statement
  • CERT, EXP52-J. - Use braces for the body of an if, for, or while statement

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

    $q = new Pluf_SQL('name=%s', array(
Severity: Minor
Found in src/Shop/Shortcuts.php by phpmd

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

Expected "function abc(...)"; found "function abc (...)"
Open

function Shop_Shortcuts_GetTagByNameOr404 ($name)
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Expected 0 spaces before opening parenthesis; 1 found
Open

function Shop_Shortcuts_GetTagByNameOr404 ($name)
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Inline control structures are not allowed
Open

    if ($count > 30)
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Inline control structures are not allowed
Open

    if (isset($mapper[$itemType]))
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Closing parenthesis of a multi-line function call must be on a line by itself
Open

            sprintf('more than one tag exist with the name $s', $name));
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Expected 1 newline at end of file; 0 found
Open

}
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Whitespace found at end of line
Open

 * @param Pluf_Model $model2            
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            sprintf('more than one tag exist with the name $s', $name));
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Closing parenthesis of a multi-line function call must be on a line by itself
Open

        "Tag not found (Tag name:" . $name . ")");
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Whitespace found at end of line
Open

 * 
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Whitespace found at end of line
Open

 * @param string $itemType            
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Whitespace found at end of line
Open

 * @param Pluf_Model $model1            
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Whitespace found at end of line
Open

 * @param Pluf_Model $model            
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        "Tag not found (Tag name:" . $name . ")");
Severity: Minor
Found in src/Shop/Shortcuts.php by phpcodesniffer

There are no issues that match your filters.

Category
Status