Formula9/Framework

View on GitHub

Showing 487 of 487 total issues

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

    private function importDeclaration($configurationType, $definition)
    {
        switch ($configurationType) {
            case 'add':
                $this->registerAdds($definition);
Severity: Minor
Found in F9/Container/WithConfigurableInjector.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 set_loader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function set_loader($configuration)
    {
        switch (TRUE) {

            case ($this->template_type === static::TWIG_LOADER_ARRAY):
Severity: Minor
Found in Nine/Views/TwigView.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 encode_readable_json has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function encode_readable_json($data, $indent = 0)
    {
        $_escape = function ($str) {
            return preg_replace("!([\b\t\n\r\f\"\\'])!", "\\\\\\1", $str);
        };
Severity: Minor
Found in Nine/Library/Strings.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

Method subRequest has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        string $uri,
        string $method = 'GET',
        array $parameters = [],
        array $cookies = [],
        array $files = [],
Severity: Major
Found in F9/Application/Application.php - About 50 mins to fix

    The parameter $mark_down is not named in camelCase.
    Open

        public function translate_template_data($mark_down, array $data = [])
        {
            // @{<include_template_name>}
            $mark_down = preg_replace_callback('$\@\{\s*\w*.md\s*\}$',
                function ($match) use ($data) {
    Severity: Minor
    Found in Nine/Views/MarkdownView.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

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

            array_walk_recursive($array, function ($x) use (&$return) {
    Severity: Minor
    Found in Nine/Library/Arrays.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

    The parameter $camel_case_string is not named in camelCase.
    Open

        public static function camel_to_snake($camel_case_string, $delimiter = '_')
        {
            preg_match_all(
                '!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!',
                $camel_case_string,
    Severity: Minor
    Found in Nine/Library/Strings.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

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

                $a = [];
    Severity: Minor
    Found in Nine/Library/Strings.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

    The parameter $template_name is not named in camelCase.
    Open

        public function hasView($template_name) : bool
        {
            throw new \Twig_Error_Runtime('hasView not implemented.');
        }
    Severity: Minor
    Found in Nine/Views/TwigView.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $target_value is not named in camelCase.
    Open

        public static function from_notation($dot_path, &$target_array, $target_value = NULL)
        {
            $result_array = &$target_array;
    
            foreach (explode('.', $dot_path) as $step) {
    Severity: Minor
    Found in Nine/Library/Arrays.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $suffix_to_remove is not named in camelCase.
    Open

        public static function alias_from_class($class_name, $suffix_to_remove = '')
        {
            return strtolower(static::remove_namespace($class_name, $suffix_to_remove));
        }
    Severity: Minor
    Found in Nine/Library/Support.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $class_name is not named in camelCase.
    Open

        public static function remove_namespace($class_name, $class_suffix = NULL)
        {
            $segments = explode('\\', $class_name);
            $class = $segments[count($segments) - 1];
            if ( ! is_null($class_suffix)) {
    Severity: Minor
    Found in Nine/Library/Support.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

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

            array_walk_recursive($array, function ($x) use (&$return) {

    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 property $template_type is not named in camelCase.
    Open

    class TwigView extends AbstractView
    {
        const TWIG_LOADER_ARRAY  = 1;
        const TWIG_LOADER_STRING = 2;
        const TWIG_LOADER_CHAIN  = 3;
    Severity: Minor
    Found in Nine/Views/TwigView.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 parameter $class_suffix is not named in camelCase.
    Open

        public static function remove_namespace($class_name, $class_suffix = NULL)
        {
            $segments = explode('\\', $class_name);
            $class = $segments[count($segments) - 1];
            if ( ! is_null($class_suffix)) {
    Severity: Minor
    Found in Nine/Library/Support.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $merge_data is not named in camelCase.
    Open

        public function collectScope(array $merge_data = [])
        {
            return $this->scope->merge($merge_data);
        }
    Severity: Minor
    Found in Nine/Views/AbstractView.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $double_encode is not named in camelCase.
    Open

        public static function hsc($string, $double_encode = TRUE)
        {
            return htmlspecialchars($string, ENT_COMPAT | ENT_HTML5, 'UTF-8', $double_encode);
        }
    Severity: Minor
    Found in Nine/Library/Strings.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $context_settings is not named in camelCase.
    Open

        public function __construct($context_settings)
        {
            parent::__construct($context_settings);
        }
    Severity: Minor
    Found in Nine/Views/BladeConfigurationSet.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $template_paths is not named in camelCase.
    Open

        public function addPaths($template_paths)
        {
            foreach ($template_paths as $template_path)
                $this->addPath($template_path);
    
    
    Severity: Minor
    Found in Nine/Views/MarkdownView.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $target_array is not named in camelCase.
    Open

        public static function from_notation($dot_path, &$target_array, $target_value = NULL)
        {
            $result_array = &$target_array;
    
            foreach (explode('.', $dot_path) as $step) {
    Severity: Minor
    Found in Nine/Library/Arrays.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    Severity
    Category
    Status
    Source
    Language