| Conditions | 7 |
| Paths | 24 |
| Total Lines | 55 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 56 | public function analyze($deletedFiles, $writtenFiles) |
||
| 57 | { |
||
| 58 | // prepare data |
||
| 59 | $entropyOfDeletedFiles = []; |
||
| 60 | $entropyOfWrittenFiles = []; |
||
| 61 | $standardDeviationOfDeletedFiles = []; |
||
| 62 | $standardDeviationOfWrittenFiles = []; |
||
| 63 | $numberOfInfoFiles = 0; |
||
| 64 | |||
| 65 | foreach ($deletedFiles as $deletedFile) { |
||
| 66 | array_push($entropyOfDeletedFiles, $deletedFile->getEntropy()); |
||
| 67 | array_push($standardDeviationOfDeletedFiles, $deletedFile->getStandardDeviation()); |
||
| 68 | } |
||
| 69 | foreach ($writtenFiles as $writtenFile) { |
||
| 70 | // remove the entropy of info files from $entropyOfWrittenFiles |
||
| 71 | if ($writtenFile->getSuspicionClass() === Classifier::NOT_SUSPICIOUS) { |
||
| 72 | if ($numberOfInfoFiles < SequenceAnalyzer::NUMBER_OF_INFO_FILES) { |
||
| 73 | $numberOfInfoFiles++; |
||
| 74 | break; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | array_push($entropyOfWrittenFiles, $writtenFile->getEntropy()); |
||
| 78 | array_push($standardDeviationOfWrittenFiles, $writtenFile->getStandardDeviation()); |
||
| 79 | } |
||
| 80 | |||
| 81 | // analyze data |
||
| 82 | $entropyFunnellingResult = new EntropyFunnellingResult(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0); |
||
| 83 | $medianOfEntropyDeleted = $this->median($entropyOfDeletedFiles); |
||
| 84 | $medianOfEntropyWritten = $this->median($entropyOfWrittenFiles); |
||
| 85 | $entropyFunnellingResult->setMedianDeleted($medianOfEntropyDeleted); |
||
| 86 | $entropyFunnellingResult->setMedianWritten($medianOfEntropyWritten); |
||
| 87 | |||
| 88 | $entropyFunnellingScore = 0; |
||
| 89 | |||
| 90 | $rangeOfEntropyDeleted = $this->range($entropyOfDeletedFiles); |
||
| 91 | $rangeOfStandardDeviationDeleted = $this->average($standardDeviationOfDeletedFiles); |
||
| 92 | $rangeOfEntropyWritten = $this->range($entropyOfWrittenFiles); |
||
| 93 | $rangeOfStandardDeviationWritten = $this->average($standardDeviationOfWrittenFiles); |
||
| 94 | $entropyFunnellingResult->setRangeOfEntropyDeleted($rangeOfEntropyDeleted); |
||
| 95 | $entropyFunnellingResult->setRangeOfEntropyWritten($rangeOfEntropyWritten); |
||
| 96 | $entropyFunnellingResult->setRangeOfStandardDeviationDeleted($rangeOfStandardDeviationDeleted); |
||
| 97 | $entropyFunnellingResult->setRangeOfStandardDeviationWritten($rangeOfStandardDeviationWritten); |
||
| 98 | |||
| 99 | // range of $entropyOfDeletedFiles must be wider than range of $entropyOfWrittenFiles |
||
| 100 | if ($rangeOfEntropyDeleted > $rangeOfEntropyWritten) { |
||
| 101 | $entropyFunnellingScore = $entropyFunnellingScore + 1; |
||
| 102 | // range of $standardDeviationOfDeletedFiles must be wider than range of $standardDeviationOfWrittenFiles |
||
| 103 | if ($rangeOfStandardDeviationDeleted > $rangeOfStandardDeviationWritten) { |
||
| 104 | $entropyFunnellingScore = $entropyFunnellingScore + 1; |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | $entropyFunnellingResult->setEntropyFunnelling($entropyFunnellingScore); |
||
| 109 | |||
| 110 | return $entropyFunnellingResult; |
||
| 111 | } |
||
| 167 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths