ecoco/magento_profiler

View on GitHub
app/code/community/Ecocode/Profiler/Helper/Data.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

    protected function getClassNames($reload = false)
    {
        if ($this->classNameCache !== null && $reload === false) {
            return $this->classNameCache;
        }
Severity: Minor
Found in app/code/community/Ecocode/Profiler/Helper/Data.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 getVersion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getVersion()
    {
        if (self::$version === null && class_exists('Mage') && $config = Mage::getConfig()) {
            //try to load from magento
            $config = $config->getModuleConfig('Ecocode_Profiler');
Severity: Minor
Found in app/code/community/Ecocode/Profiler/Helper/Data.php - About 45 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

Avoid too many return statements within this method.
Open

        return false;
Severity: Major
Found in app/code/community/Ecocode/Profiler/Helper/Data.php - About 30 mins to fix

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

        protected function shouldRemoveBacktraceItem(array $data, array $ignoreCalls = [], array $ignoreInstanceOf = [])
        {
            //remove if not called from a class
            if (!isset($data['class'], $data['function'])) {
                return true;
    Severity: Minor
    Found in app/code/community/Ecocode/Profiler/Helper/Data.php - 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

    Missing class import via use statement (line '47', column '27').
    Open

                    throw new RuntimeException('unable to determinate profiler version');

    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 '48').
    Open

                $this->configClassReflection = new ReflectionProperty('Mage_Core_Model_Config', '_classNameCache');

    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 assigning values to variables in if clauses and the like (line '33', column '64').
    Open

        public static function getVersion()
        {
            if (self::$version === null && class_exists('Mage') && $config = Mage::getConfig()) {
                //try to load from magento
                $config = $config->getModuleConfig('Ecocode_Profiler');

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

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

        protected $configClassReflection;

    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

    There are no issues that match your filters.

    Category
    Status