attogram/attogram

View on GitHub

Showing 308 of 308 total issues

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

    public function setModuleTemplates()
    {
        $dirs = $this->getAllSubdirectories($this->modulesDirectory, 'templates');
        if (!$dirs) {
            //$this->log->debug('setModuleTemplates: no module templates found. Using defaults.');
Severity: Minor
Found in Attogram/Attogram.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

Consider simplifying this complex logical expression.
Open

        if (!$file || !$type || $type == '' || !is_string($type) || !is_string($file) || !is_readable($file)) {
            return false;
        }
Severity: Major
Found in Attogram/Attogram.php - About 40 mins to fix

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

            \Psr\Log\LoggerInterface $log,
            \Psr\Log\LoggerInterface $event,
            \Attogram\AttogramDatabaseInterface $database,
            \Symfony\Component\HttpFoundation\Request $request,
            array $config = array()
    Severity: Minor
    Found in Attogram/Attogram.php - About 35 mins to fix

      Method guruMeditationErrorHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $level,
              $message,
              $file = '',
              $line = '',
              $context = array()
      Severity: Minor
      Found in public/index.php - About 35 mins to fix

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                        if (preg_match('/ErrorDocument\s+404/', $val)) {
                            ++$count['ErrorDocument 404'];
                            if (preg_match('/ErrorDocument\s+404\s+(.*)\s+$/', $val, $match)) {
                                $found['ErrorDocument 404'] = trim($match[1]);
                                if (trim($match[1]) == $goodUri) {
        Severity: Minor
        Found in public/check.php and 2 other locations - About 35 mins to fix
        public/check.php on lines 97..106
        public/check.php on lines 107..116

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 92.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                        if (preg_match('/FallbackResource/', $val)) {
                            ++$count['FallbackResource'];
                            if (preg_match('/FallbackResource\s+(.*)\s+$/', $val, $match)) {
                                $found['FallbackResource'] = trim($match[1]);
                                if (trim($match[1]) == $goodUri) {
        Severity: Minor
        Found in public/check.php and 2 other locations - About 35 mins to fix
        public/check.php on lines 107..116
        public/check.php on lines 117..126

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 92.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                        if (preg_match('/ErrorDocument\s+403/', $val)) {
                            ++$count['ErrorDocument 403'];
                            if (preg_match('/ErrorDocument\s+403\s+(.*)\s+$/', $val, $match)) {
                                $found['ErrorDocument 403'] = trim($match[1]);
                                if (trim($match[1]) == $goodUri) {
        Severity: Minor
        Found in public/check.php and 2 other locations - About 35 mins to fix
        public/check.php on lines 97..106
        public/check.php on lines 117..126

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 92.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            public function defaultHomepage()
            {
                $this->log->error('using defaultHomepage');
                $this->pageHeader('Home');
                echo '<div class="container">'
        Severity: Minor
        Found in Attogram/Attogram.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 guruMeditationErrorHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function guruMeditationErrorHandler(
                $level,
                $message,
                $file = '',
                $line = '',
        Severity: Minor
        Found in public/index.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 checkIndex has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function checkIndex()
            {
                $indexFile = './index.php';
                file_exists($indexFile) ? $fileexists = 'pass' : $fileexists = 'fail';
                echo '<pre class="'.$fileexists.'">'.$this->{$fileexists}.' 1.0 - <strong>'.$indexFile.'</strong> exists</pre>';
        Severity: Minor
        Found in public/check.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 closing brace must go on the next line following the body; found 1 blank lines before brace
        Open

            } // end function __construct()
        Severity: Minor
        Found in public/index.php by phpcodesniffer

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

            public static function includeAllPhpFilesInDirectory($dir)
            {
                $included = array();
                if (!is_readable($dir)) {
                    return $included;
        Severity: Minor
        Found in Attogram/Attogram.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 closing brace must go on the next line following the body; found 1 blank lines before brace
        Open

            } // end function tranquility()
        Severity: Minor
        Found in public/index.php by phpcodesniffer

        Avoid too many return statements within this method.
        Open

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

          Avoid too many return statements within this method.
          Open

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

            Remove error control operator '@' on line 123.
            Open

                public function awaken()
                {
                    // The Site Administrator IP addresses
                    $this->remember(
                        'admins',
            Severity: Minor
            Found in Attogram/Attogram.php by phpmd

            ErrorControlOperator

            Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

            Example

            function foo($filePath) {
                $file = @fopen($filPath); // hides exceptions
                $key = @$array[$notExistingKey]; // assigns null to $key
            }

            Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

            Avoid too many return statements within this method.
            Open

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

              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 '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

                Remove error control operator '@' on line 592.
                Open

                    public function isAdmin()
                    {
                        if (isset($this->isAdmin) && is_bool($this->isAdmin)) {
                            return $this->isAdmin;
                        }
                Severity: Minor
                Found in Attogram/Attogram.php by phpmd

                ErrorControlOperator

                Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

                Example

                function foo($filePath) {
                    $file = @fopen($filPath); // hides exceptions
                    $key = @$array[$notExistingKey]; // assigns null to $key
                }

                Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

                Severity
                Category
                Status
                Source
                Language