| Conditions | 1 |
| Paths | 1 |
| Total Lines | 89 |
| Code Lines | 66 |
| 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 |
||
| 45 | public function getCMSFields() { |
||
| 46 | $this->beforeUpdateCMSFields(function (FieldList $fields) { |
||
| 47 | // Main Content tab |
||
| 48 | $fields->addFieldToTab( |
||
| 49 | 'Root.Main', |
||
| 50 | TreeDropdownField::create( |
||
| 51 | 'LearnMorePageID', |
||
| 52 | _t('BaseHomePage.LearnMoreLink','Page to link the "Learn More" button to:'), |
||
| 53 | 'SiteTree' |
||
| 54 | ), |
||
| 55 | 'Metadata' |
||
| 56 | ); |
||
| 57 | |||
| 58 | $gridField = GridField::create( |
||
| 59 | 'Quicklinks', |
||
| 60 | 'Quicklinks', |
||
| 61 | $this->Quicklinks(), |
||
| 62 | GridFieldConfig_RelationEditor::create() |
||
| 63 | ); |
||
| 64 | $gridConfig = $gridField->getConfig(); |
||
| 65 | $gridConfig->getComponentByType('GridFieldAddNewButton')->setButtonName( |
||
| 66 | _t('BaseHomePage.AddNewButton','Add new') |
||
| 67 | ); |
||
| 68 | $gridConfig->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
||
| 69 | $gridConfig->removeComponentsByType('GridFieldDeleteAction'); |
||
| 70 | $gridConfig->addComponent(new GridFieldDeleteAction()); |
||
| 71 | $gridConfig->addComponent(new GridFieldSortableRows('SortOrder')); |
||
| 72 | $gridField->setModelClass('Quicklink'); |
||
| 73 | |||
| 74 | $fields->addFieldToTab('Root.Quicklinks', $gridField); |
||
| 75 | |||
| 76 | $fields->removeByName('Import'); |
||
| 77 | |||
| 78 | $fields->addFieldToTab( |
||
| 79 | 'Root.Features', |
||
| 80 | ToggleCompositeField::create('FeatureOne', _t('SiteTree.FeatureOne', 'Feature One'), |
||
| 81 | array( |
||
| 82 | TextField::create('FeatureOneTitle', _t('BaseHomePage.Title','Title')), |
||
| 83 | $dropdownField = DropdownField::create( |
||
| 84 | 'FeatureOneCategory', |
||
| 85 | _t('BaseHomePage.FeatureCategoryDropdown','Category icon'), |
||
| 86 | singleton('BaseHomePage')->dbObject('FeatureOneCategory')->enumValues() |
||
| 87 | ), |
||
| 88 | HTMLEditorField::create( |
||
| 89 | 'FeatureOneContent', |
||
| 90 | _t('BaseHomePage.FeatureContentFieldLabel','Content') |
||
| 91 | ), |
||
| 92 | TextField::create( |
||
| 93 | 'FeatureOneButtonText', |
||
| 94 | _t('BaseHomePage.FeatureButtonText','Button text') |
||
| 95 | ), |
||
| 96 | TreeDropdownField::create( |
||
| 97 | 'FeatureOneLinkID', |
||
| 98 | _t('BaseHomePage.FeatureLink','Page to link to'), |
||
| 99 | 'SiteTree' |
||
| 100 | )->setDescription(_t('BaseHomePage.ButtonTextRequired','Button text must be filled in')) |
||
| 101 | ) |
||
| 102 | )->setHeadingLevel(3) |
||
| 103 | ); |
||
| 104 | $dropdownField->setEmptyString('none'); |
||
| 105 | |||
| 106 | $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureTwo', _t('SiteTree.FeatureTwo', 'Feature Two'), |
||
| 107 | array( |
||
| 108 | TextField::create('FeatureTwoTitle', _t('BaseHomePage.Title','Title')), |
||
| 109 | $dropdownField = DropdownField::create( |
||
| 110 | 'FeatureTwoCategory', |
||
| 111 | _t('BaseHomePage.FeatureCategoryDropdown','Category icon'), |
||
| 112 | singleton('BaseHomePage')->dbObject('FeatureTwoCategory')->enumValues() |
||
| 113 | ), |
||
| 114 | HTMLEditorField::create( |
||
| 115 | 'FeatureTwoContent', |
||
| 116 | _t('BaseHomePage.FeatureContentFieldLabel','Content') |
||
| 117 | ), |
||
| 118 | TextField::create( |
||
| 119 | 'FeatureTwoButtonText', |
||
| 120 | _t('BaseHomePage.FeatureButtonText','Button text') |
||
| 121 | ), |
||
| 122 | TreeDropdownField::create( |
||
| 123 | 'FeatureTwoLinkID', |
||
| 124 | _t('BaseHomePage.FeatureLink','Page to link to'), |
||
| 125 | 'SiteTree' |
||
| 126 | )->setDescription(_t('BaseHomePage.ButtonTextRequired','Button text must be filled in')) |
||
| 127 | ) |
||
| 128 | )->setHeadingLevel(3) |
||
| 129 | ); |
||
| 130 | $dropdownField->setEmptyString('none'); |
||
| 131 | }); |
||
| 132 | |||
| 133 | return parent::getCMSFields(); |
||
| 134 | } |
||
| 154 |
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