.phan/plugins/PreferNamespaceUsePlugin.php

Summary

Maintainability
A
3 hrs
Test Coverage

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

    private static function analyzeFunctionLikeParam(CodeBase $code_base, FunctionInterface $method, Node $param_node): void
    {
        $param_type = $param_node->children['type'];
        if (!$param_type instanceof Node) {
            return;
Severity: Minor
Found in .phan/plugins/PreferNamespaceUsePlugin.php - About 1 hr to fix

    Function determineShorterType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function determineShorterType(Context $context, Node $type_node): ?string
        {
            if ($type_node->kind !== ast\AST_NAME) {
                return null;
            }
    Severity: Minor
    Found in .phan/plugins/PreferNamespaceUsePlugin.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

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

        private static function analyzeFunctionLikeParam(CodeBase $code_base, FunctionInterface $method, Node $param_node): void
        {
            $param_type = $param_node->children['type'];
            if (!$param_type instanceof Node) {
                return;
    Severity: Minor
    Found in .phan/plugins/PreferNamespaceUsePlugin.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

    Avoid too many return statements within this method.
    Open

            return null;
    Severity: Major
    Found in .phan/plugins/PreferNamespaceUsePlugin.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return $name_end;
      Severity: Major
      Found in .phan/plugins/PreferNamespaceUsePlugin.php - About 30 mins to fix

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

            private static function analyzeFunctionLike(CodeBase $code_base, FunctionInterface $method): void
            {
                $node = $method->getNode();
                if (!$node) {
                    return;
        Severity: Minor
        Found in .phan/plugins/PreferNamespaceUsePlugin.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

        Constant PreferNamespaceUseParamType should be defined in uppercase
        Open

            private const PreferNamespaceUseParamType = 'PhanPluginPreferNamespaceUseParamType';

        ConstantNamingConventions

        Since: 0.2

        Class/Interface constant names should always be defined in uppercase.

        Example

        class Foo {
            const MY_NUM = 0; // ok
            const myTest = ""; // fail
        }

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

        Constant PreferNamespaceUseReturnType should be defined in uppercase
        Open

            private const PreferNamespaceUseReturnType = 'PhanPluginPreferNamespaceUseReturnType';

        ConstantNamingConventions

        Since: 0.2

        Class/Interface constant names should always be defined in uppercase.

        Example

        class Foo {
            const MY_NUM = 0; // ok
            const myTest = ""; // fail
        }

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

        There are no issues that match your filters.

        Category
        Status