SergioMadness/pwf

View on GitHub

Showing 330 of 330 total issues

Function validate has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate(array $data)
    {
        $rules = $this->getRules();
        foreach ($rules as $field => $rule) {
            if ((isset($rule['required']) && $rule['required'] === true && isset($data[$field]))
Severity: Minor
Found in framework/traits/Validatable.php - About 4 hrs 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

Method getTranslator has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getTranslator($type, array $params = [])
    {
        $result = null;

        if (!isset($params['language'])) {
Severity: Minor
Found in framework/components/i18n/Fabric.php - About 2 hrs to fix

    Function getTranslator has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getTranslator($type, array $params = [])
        {
            $result = null;
    
            if (!isset($params['language'])) {
    Severity: Minor
    Found in framework/components/i18n/Fabric.php - About 1 hr 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 using short method names like Route::to(). The configured minimum method name length is 3.
    Open

        public static function to($path)
        {
            $currentLanguage = \Translation::getLanguage();
            if (\Translation::getDefaultLanguage() === $currentLanguage) {
                $currentLanguage = '';
    Severity: Minor
    Found in framework/facades/Route.php by phpmd

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

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

    Avoid using short method names like EventTrait::on(). The configured minimum method name length is 3.
    Open

        public function on($type, $callback)
        {
            if (!isset($this->callbacks[$type])) {
                $this->callbacks[$type] = [];
            }

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

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

    Avoid using short method names like EventHandler::on(). The configured minimum method name length is 3.
    Open

        public function on($type, $callback);

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

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

    Function getHandlerByPath has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getHandlerByPath($path)
        {
            $result = null;
            $path   = self::prepareRoute('/'.trim($path, " /"));
    
    
    Severity: Minor
    Found in framework/basic/RouteHandler.php - About 1 hr 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

    Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run()
        {
            try {
                $this->trigger(self::EVENT_APPLICATION_RUN);
    
    
    Severity: Minor
    Found in framework/basic/Application.php - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                  if ((isset($rule['required']) && $rule['required'] === true && isset($data[$field]))
                      || ((!isset($rule['required']) || !$rule['required'])) && isset($data[$field])) {
                      foreach ($rule as $key => $value) {
                          if ($key !== 'required') {
                              foreach ($value as $validator) {
      Severity: Major
      Found in framework/traits/Validatable.php - About 1 hr to fix

        Each class must be in a namespace of at least one level (a top-level vendor name)
        Open

        class Route
        Severity: Minor
        Found in framework/facades/Route.php by phpcodesniffer

        Each class must be in a namespace of at least one level (a top-level vendor name)
        Open

        class Config
        Severity: Minor
        Found in framework/facades/Config.php by phpcodesniffer

        Each class must be in a namespace of at least one level (a top-level vendor name)
        Open

        class Translation

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

            private $o;

        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

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

                $id         = $this->getId();
        Severity: Minor
        Found in framework/basic/db/DBModel.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

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

            public function setObject($o)

        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

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

            private $fc;

        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

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

        class QueryBuilder
        {
            /**
             * MySQL driver
             */
        Severity: Minor
        Found in framework/basic/db/QueryBuilder.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

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

            protected function forceComponentLoading()
            {
                $config = $this->getConfiguration();
                foreach ($config[self::COMPONENT_CONFIG_BLOCK] as $key => $params) {
                    if (isset($params['class']) && isset($params['force'])) {
        Severity: Minor
        Found in framework/basic/Application.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

        Multi-line function declaration not indented correctly; expected 8 spaces but found 30
        Open

                                      $type = 'text/javascript')
        Severity: Minor
        Found in framework/basic/View.php by phpcodesniffer

        Expected 1 space after FUNCTION keyword; 0 found
        Open

                        function($paramName) use ($params) {
        Severity
        Category
        Status
        Source
        Language