vpietri/magento2-developer-quickdevbar

View on GitHub
Helper/Translate.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method __construct has 14 arguments (exceeds 4 allowed). Consider refactoring.
Open

        DesignInterface $viewDesign,
        FrontendInterface $cache,
        ViewFileSystem $viewFileSystem,
        ModuleList $moduleList,
        Reader $modulesReader,
Severity: Major
Found in Helper/Translate.php - About 1 hr to fix

    Function loadModuleTranslationByModulesList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function loadModuleTranslationByModulesList(array $modules)
        {
            foreach ($modules as $module) {
                $moduleFilePath = $this->_getModuleTranslationFile($module, $this->getLocale());
                $relativePath = $this->_getRelativeFilePath($moduleFilePath);
    Severity: Minor
    Found in Helper/Translate.php - About 35 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 _loadThemeTranslation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function _loadThemeTranslation()
        {
            $file = $this->_getThemeTranslationFile($this->getLocale());
            if ($file) {
                $relativePath = $this->_getRelativeFilePath($file);
    Severity: Minor
    Found in Helper/Translate.php - About 35 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

    The method __construct has 14 parameters. Consider reducing the number of parameters to less than 10.
    Open

        public function __construct(
            DesignInterface $viewDesign,
            FrontendInterface $cache,
            ViewFileSystem $viewFileSystem,
            ModuleList $moduleList,
    Severity: Minor
    Found in Helper/Translate.php by phpmd

    The class Translate has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
    Open

    class Translate extends \Magento\Framework\Translate
    {
        /**
         * Checks if we have loaded our translation data.
         *
    Severity: Minor
    Found in Helper/Translate.php by phpmd

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    The property $_hasLoaded is not named in camelCase.
    Open

    class Translate extends \Magento\Framework\Translate
    {
        /**
         * Checks if we have loaded our translation data.
         *
    Severity: Minor
    Found in Helper/Translate.php by phpmd

    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 method _getRelativeFilePath is not named in camelCase.
    Open

        protected function _getRelativeFilePath($absolutePath)
        {
            return str_replace($this->directoryList->getRoot() . DIRECTORY_SEPARATOR, '', $absolutePath);
        }
    Severity: Minor
    Found in Helper/Translate.php by phpmd

    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 _loadDbTranslation is not named in camelCase.
    Open

        protected function _loadDbTranslation()
        {
            $this->_data['db'] = $this->_translateResource->getTranslationArray(null, $this->getLocale());
            return $this;
        }
    Severity: Minor
    Found in Helper/Translate.php by phpmd

    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 _loadPackTranslation is not named in camelCase.
    Open

        protected function _loadPackTranslation()
        {
            $this->_data['pack'] = $this->packDictionary->getDictionary($this->getLocale());
            return $this;
        }
    Severity: Minor
    Found in Helper/Translate.php by phpmd

    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 _loadThemeTranslation is not named in camelCase.
    Open

        protected function _loadThemeTranslation()
        {
            $file = $this->_getThemeTranslationFile($this->getLocale());
            if ($file) {
                $relativePath = $this->_getRelativeFilePath($file);
    Severity: Minor
    Found in Helper/Translate.php by phpmd

    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