ecoco/magento_profiler

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

Summary

Maintainability
A
1 hr
Test Coverage

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

    public function formatQuery($sql, $highlightOnly = false)
    {
        if (@!class_exists('SqlFormatter')) {
            return 'SqlFormatter is not installed';
        }
Severity: Minor
Found in app/code/community/Ecocode/Profiler/Helper/Sql.php - About 1 hr to fix

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

                $dumper = new \Symfony\Component\Yaml\Dumper();

    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

    Remove error control operator '@' on line 46.
    Open

        public function dumpParameters(array $parameters)
        {
            if (!$parameters) {
                return '{}';
            }

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

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

    Remove error control operator '@' on line 68.
    Open

        public function formatQuery($sql, $highlightOnly = false)
        {
            if (@!class_exists('SqlFormatter')) {
                return 'SqlFormatter is not installed';
            }

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

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

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

        protected $formattedQueriesCache = [];

    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