attogram/attogram

View on GitHub

Showing 308 of 308 total issues

Missing class import via use statement (line '231', column '26').
Open

            $event = new \Psr\Log\NullLogger();
Severity: Minor
Found in public/index.php by phpmd

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

Missing class import via use statement (line '448', column '23').
Open

        $parser = new \ParsedownExtra();
Severity: Minor
Found in Attogram/Attogram.php by phpmd

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

Avoid too many return statements within this method.
Open

                return;
Severity: Major
Found in public/index.php - About 30 mins to fix

    Missing class import via use statement (line '210', column '24').
    Open

                $log = new \Psr\Log\NullLogger();
    Severity: Minor
    Found in public/index.php by phpmd

    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

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

        public function meditate()
        {
            // Set default configuration
            $this->config = array();
            $this->config['attogramDirectory']  = '..'.DIRECTORY_SEPARATOR;
    Severity: Minor
    Found in public/index.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

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

        public function checkApache()
        {
            isset($_SERVER['SERVER_SOFTWARE'])
                ? $serverSoftware = $_SERVER['SERVER_SOFTWARE'] : $serverSoftware = '';
            $serverSoftwareArray = explode(' ', $serverSoftware);
    Severity: Minor
    Found in public/check.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

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

        public function exceptionFiles()
        {
            switch ($this->request->getPathInfo()) {
                case '/robots.txt':
                    header('Content-Type: text/plain; charset=utf-8');
    Severity: Minor
    Found in Attogram/Attogram.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

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

        public function isAdmin()
        {
            if (isset($this->isAdmin) && is_bool($this->isAdmin)) {
                return $this->isAdmin;
            }
    Severity: Minor
    Found in Attogram/Attogram.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

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

        public function awaken()
        {
            // The Site Administrator IP addresses
            $this->remember(
                'admins',
    Severity: Minor
    Found in Attogram/Attogram.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

    The method checkHtaccess() has an NPath complexity of 166216. The configured NPath complexity threshold is 200.
    Open

        public function checkHtaccess()
        {
            $htaccessFile = './.htaccess';
            file_exists($htaccessFile) ? $result = 'pass' : $result = 'fail';
            echo '<pre class="'.$result.'">'.$this->{$result}.' 2.0 - <strong>'
    Severity: Minor
    Found in public/check.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    Avoid using static access to class '\Symfony\Component\HttpFoundation\Request' in method 'tranquility'.
    Open

            $request = Request::createFromGlobals();
    Severity: Minor
    Found in public/index.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class 'Attogram\Attogram' in method 'meditateDeeper'.
    Open

            $configDirs = Attogram::getAllSubdirectories(
                $this->config['modulesDirectory'],
                'configs'
            );
    Severity: Minor
    Found in public/index.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class 'Attogram\Attogram' in method 'meditateDeeper'.
    Open

                Attogram::includeAllPhpFilesInDirectory($dir);
    Severity: Minor
    Found in public/index.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    The method virtualWebDirectory() has an NPath complexity of 288. The configured NPath complexity threshold is 200.
    Open

        public function virtualWebDirectory()
        {
            if (!preg_match('/^\/'.'web'.'\//', $this->request->getPathInfo())) {
                return; // not a virtual web directory request
            }
    Severity: Minor
    Found in Attogram/Attogram.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    The method shutdown() contains an exit expression.
    Open

            exit; // The Final Exit
    Severity: Minor
    Found in Attogram/Attogram.php by phpmd

    ExitExpression

    Since: 0.2

    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

    Example

    class Foo {
        public function bar($param)  {
            if ($param === 42) {
                exit(23);
            }
        }
    }

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

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

        public function tabler(
            $table,
            $tableId,
            $nameSingular,
            $namePlural,
    Severity: Minor
    Found in Attogram/NullDatabase.php by phpmd

    Avoid unused local variables such as '$trash'.
    Open

            $trash = array_shift($test); // take off top level
    Severity: Minor
    Found in Attogram/Attogram.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$trash'.
    Open

                $trash = array_shift($this->uri); // take off first blank entry
    Severity: Minor
    Found in Attogram/Attogram.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    The method guruMeditationError() contains an exit expression.
    Open

            exit; // Exit everything
    Severity: Minor
    Found in public/index.php by phpmd

    ExitExpression

    Since: 0.2

    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

    Example

    class Foo {
        public function bar($param)  {
            if ($param === 42) {
                exit(23);
            }
        }
    }

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

    The method guruMeditationErrorHandler() has an NPath complexity of 306. The configured NPath complexity threshold is 200.
    Open

        public function guruMeditationErrorHandler(
            $level,
            $message,
            $file = '',
            $line = '',
    Severity: Minor
    Found in public/index.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    Severity
    Category
    Status
    Source
    Language