Conditions | 3 |
Paths | 4 |
Total Lines | 83 |
Code Lines | 60 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
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 |
||
68 | public function updateCMSFields(FieldList $fields) |
||
69 | { |
||
70 | $fields->removeByName('UnderConstructionOutcome'); |
||
71 | $fields->addFieldsToTab( |
||
72 | 'Root.Offline', |
||
73 | [ |
||
74 | ReadonlyField::create( |
||
75 | 'UnderConstructionOutcome', |
||
76 | 'Status ...' |
||
77 | ) |
||
78 | ->setDescription('Was the last action successful? Are there any worries?'), |
||
79 | OptionsetField::create( |
||
80 | 'UnderConstructionOnOff', |
||
81 | 'Is the site Online or Offline', |
||
82 | ['Online' => 'Online', 'Offline' => 'Offline'] |
||
83 | ) |
||
84 | ->setDescription('Make the site go Online / Offline. Please use with care!'), |
||
85 | NumericField::create( |
||
86 | 'UnderConstructionMinutesOffline', |
||
87 | 'Minutes Offline' |
||
88 | ) |
||
89 | ->setDescription('Indication to the user for how long the site will be offline.'), |
||
90 | TextField::create( |
||
91 | 'UnderConstructionTitle', |
||
92 | 'Page Title' |
||
93 | ), |
||
94 | TextField::create( |
||
95 | 'UnderConstructionSubTitle', |
||
96 | 'Page Sub-Title' |
||
97 | ), |
||
98 | TextField::create( |
||
99 | 'UnderConstructionExcludedIps', |
||
100 | 'Excluded IPs' |
||
101 | ) |
||
102 | ->setDescription('Separated by comma. Your IP address (' . Controller::curr()->getRequest()->getIp() . ') will be added automatically.'), |
||
103 | UploadField::create( |
||
104 | 'UnderConstructionImage', |
||
105 | 'Background Image' |
||
106 | ) |
||
107 | ->setFolderName('offline/images') |
||
108 | ->setAllowedFileCategories('image') |
||
109 | ->setIsMultiUpload(false), |
||
110 | DropdownField::create( |
||
111 | 'UnderConstructionForegroundColour', |
||
112 | 'Text Colour', |
||
113 | Config::inst()->get(CalculatedValues::class, 'under_construction_fg_options') |
||
114 | ), |
||
115 | DropdownField::create( |
||
116 | 'UnderConstructionBackgroundColour', |
||
117 | 'Background Colour', |
||
118 | Config::inst()->get(CalculatedValues::class, 'under_construction_bg_options') |
||
119 | ), |
||
120 | |||
121 | ] |
||
122 | ); |
||
123 | if ($this->owner->UnderConstructionOnOff === 'Offline') { |
||
124 | $fields->replaceField( |
||
125 | 'UnderConstructionExcludedIps', |
||
126 | ReadonlyField::create('UnderConstructionExcludedIps', 'Allowed IP Addresses') |
||
127 | ->setDescription('This can only be changed when the site is Online.') |
||
128 | ); |
||
129 | } |
||
130 | if ($this->getUnderConstructionCalculatedValues()->UnderConstructionIsReady()) { |
||
131 | $publicUrl = $this->getUnderConstructionCalculatedValues()->UnderConstructionUrlPath(); |
||
132 | $html = '<a href="' . $publicUrl . '" target="_offline">' . $publicUrl . '</a>'; |
||
133 | } else { |
||
134 | $html = 'No offline page has been created yet.'; |
||
135 | } |
||
136 | $fields->addFieldsToTab( |
||
137 | 'Root.Offline', |
||
138 | [ |
||
139 | ReadonlyField::create( |
||
140 | 'UnderConstructionPublicUrl', |
||
141 | 'Preview', |
||
142 | DBField::create_field( |
||
143 | 'HTMLText', |
||
144 | $html |
||
145 | ), |
||
146 | ), |
||
147 | ], |
||
148 | 'UnderConstructionMinutesOffline', |
||
149 | ); |
||
150 | return $fields; |
||
151 | } |
||
212 |
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