antimalware/manul

View on GitHub
src/scanner/classes/MalwareDetector.inc.php

Summary

Maintainability
D
2 days
Test Coverage

Function detectMalware has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    function detectMalware($filePath, &$foundFragment, &$pos, $startTime, $timeout, $ext)
    {

        if (filesize($filePath) > $this->MAX_FILESIZE) {
            return 'skipped';
Severity: Minor
Found in src/scanner/classes/MalwareDetector.inc.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

File MalwareDetector.inc.php has 327 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

ob_start();
require_once('XmlValidator.inc.php');
require_once('FileInfo.inc.php');
Severity: Minor
Found in src/scanner/classes/MalwareDetector.inc.php - About 3 hrs to fix

    Method detectMalware has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function detectMalware($filePath, &$foundFragment, &$pos, $startTime, $timeout, $ext)
        {
    
            if (filesize($filePath) > $this->MAX_FILESIZE) {
                return 'skipped';
    Severity: Major
    Found in src/scanner/classes/MalwareDetector.inc.php - About 3 hrs to fix

      Function malwareScanRound has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          function malwareScanRound()
          {
      
              global $php_errormsg;
      
      
      Severity: Minor
      Found in src/scanner/classes/MalwareDetector.inc.php - About 2 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 malwareScanRound has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function malwareScanRound()
          {
      
              global $php_errormsg;
      
      
      Severity: Major
      Found in src/scanner/classes/MalwareDetector.inc.php - About 2 hrs to fix

        Method repackXMLLog has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function repackXMLLog()
            {
                global $projectRootDir;
        
                $xmlLogFilename = $this->XML_LOG_FILENAME;
        Severity: Minor
        Found in src/scanner/classes/MalwareDetector.inc.php - About 1 hr to fix

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

              function checkForValidPhp($content)
              {
                  $len = strlen($content);
                  $start = 0;
                  $valid = false;
          Severity: Minor
          Found in src/scanner/classes/MalwareDetector.inc.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

          Function repackXMLLog has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              function repackXMLLog()
              {
                  global $projectRootDir;
          
                  $xmlLogFilename = $this->XML_LOG_FILENAME;
          Severity: Minor
          Found in src/scanner/classes/MalwareDetector.inc.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 detectMalware has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              function detectMalware($filePath, &$foundFragment, &$pos, $startTime, $timeout, $ext)
          Severity: Minor
          Found in src/scanner/classes/MalwareDetector.inc.php - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $attrSeverity;
            Severity: Major
            Found in src/scanner/classes/MalwareDetector.inc.php - About 30 mins to fix

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

                  function buildQuarantineArchive()
                  {
                      if (file_exists($this->MALWARE_QUARANTINE_FILENAME)) {
                          $list = file($this->MALWARE_QUARANTINE_FILENAME);
              
              
              Severity: Minor
              Found in src/scanner/classes/MalwareDetector.inc.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

              There are no issues that match your filters.

              Category
              Status