| Conditions | 5 |
| Paths | 16 |
| Total Lines | 70 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 86 | public function testReportFields() |
||
| 87 | { |
||
| 88 | $report = SitewideContentReport::create(); |
||
| 89 | |||
| 90 | // Test pages view |
||
| 91 | $gridField = $report->getReportField('Pages'); |
||
| 92 | |||
| 93 | /* @var $columns GridFieldDataColumns */ |
||
| 94 | $columns = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class); |
||
| 95 | $displayed = $columns->getDisplayFields($gridField); |
||
| 96 | |||
| 97 | $this->assertArrayHasKey('Title', $displayed); |
||
| 98 | $this->assertArrayHasKey('Created', $displayed); |
||
| 99 | $this->assertArrayHasKey('LastEdited', $displayed); |
||
| 100 | $this->assertArrayHasKey('i18n_singular_name', $displayed); |
||
| 101 | $this->assertArrayHasKey('StageState', $displayed); |
||
| 102 | |||
| 103 | // Use correct link |
||
| 104 | $this->assertArrayHasKey('RelativeLink', $displayed); |
||
| 105 | $this->assertArrayNotHasKey('AbsoluteLink', $displayed); |
||
| 106 | |||
| 107 | if (class_exists(Subsite::class)) { |
||
| 108 | $this->assertArrayHasKey('SubsiteName', $displayed); |
||
| 109 | } else { |
||
| 110 | $this->assertArrayNotHasKey('SubsiteName', $displayed); |
||
| 111 | } |
||
| 112 | |||
| 113 | // Export-only fields are not in display list |
||
| 114 | $this->assertArrayNotHasKey('Terms', $displayed); |
||
| 115 | $this->assertArrayNotHasKey('OwnerNames', $displayed); |
||
| 116 | $this->assertArrayNotHasKey('ReviewDate', $displayed); |
||
| 117 | $this->assertArrayNotHasKey('MetaDescription', $displayed); |
||
| 118 | |||
| 119 | // Tests print / export field |
||
| 120 | /* @var $export GridFieldExportButton */ |
||
| 121 | $export = $gridField->getConfig()->getComponentByType(GridFieldExportButton::class); |
||
| 122 | $exported = $export->getExportColumns(); |
||
| 123 | |||
| 124 | // Make sure all shared columns are in this report |
||
| 125 | $this->assertArrayHasKey('Title', $exported); |
||
| 126 | $this->assertArrayHasKey('Created', $exported); |
||
| 127 | $this->assertArrayHasKey('LastEdited', $exported); |
||
| 128 | $this->assertArrayHasKey('i18n_singular_name', $exported); |
||
| 129 | $this->assertArrayHasKey('StageState', $exported); |
||
| 130 | |||
| 131 | // Export-only fields |
||
| 132 | $this->assertArrayHasKey('MetaDescription', $exported); |
||
| 133 | |||
| 134 | // Use correct link |
||
| 135 | $this->assertArrayHasKey('AbsoluteLink', $exported); |
||
| 136 | $this->assertArrayNotHasKey('RelativeLink', $exported); |
||
| 137 | |||
| 138 | if (class_exists(Subsite::class)) { |
||
| 139 | $this->assertArrayHasKey('SubsiteName', $exported); |
||
| 140 | } else { |
||
| 141 | $this->assertArrayNotHasKey('SubsiteName', $exported); |
||
| 142 | } |
||
| 143 | |||
| 144 | if (SitewideContentTaxonomy::enabled()) { |
||
| 145 | $this->assertArrayHasKey('Terms', $exported); |
||
| 146 | } else { |
||
| 147 | $this->assertArrayNotHasKey('Terms', $exported); |
||
| 148 | } |
||
| 149 | |||
| 150 | if (class_exists(SiteTreeContentReview::class)) { |
||
| 151 | $this->assertArrayHasKey('OwnerNames', $exported); |
||
| 152 | $this->assertArrayHasKey('ReviewDate', $exported); |
||
| 153 | } else { |
||
| 154 | $this->assertArrayNotHasKey('OwnerNames', $exported); |
||
| 155 | $this->assertArrayNotHasKey('ReviewDate', $exported); |
||
| 156 | } |
||
| 159 |
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