| Conditions | 1 |
| Paths | 1 |
| Total Lines | 96 |
| 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 // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
||
| 67 | public function provideExecute() { |
||
| 68 | return array( |
||
| 69 | 'Normal run' => array( |
||
| 70 | array(), |
||
| 71 | array(), |
||
| 72 | 1, |
||
| 73 | <<<'EOF' |
||
| 74 | <warning>/base/path/changelog/duplicate-headers:3: Duplicate header "Type", previously seen on line 2. |
||
| 75 | /base/path/changelog/no-entry-not-patch:5: Changelog entry may only be empty when Significance is "patch". |
||
| 76 | <warning>/base/path/changelog/unknown-header:3: Unrecognized header "Bogus". |
||
| 77 | /base/path/changelog/wrong-header-values:1: Significance must be "patch", "minor", or "major". |
||
| 78 | /base/path/changelog/wrong-header-values:2: Type must be must be "security", "added", "changed", "deprecated", "removed", or "fixed". |
||
| 79 | /base/path/changelog/wrong-headers: File does not contain a Significance header. |
||
| 80 | /base/path/changelog/wrong-headers: File does not contain a Type header. |
||
| 81 | <warning>/base/path/changelog/wrong-headers:1: Unrecognized header "Significants". |
||
| 82 | <warning>/base/path/changelog/wrong-headers:2: Unrecognized header "Typo". |
||
| 83 | EOF |
||
| 84 | , |
||
| 85 | ), |
||
| 86 | 'Verbose run' => array( |
||
| 87 | array( '-v' ), |
||
| 88 | array( 'verbosity' => OutputInterface::VERBOSITY_VERBOSE ), |
||
| 89 | 1, |
||
| 90 | <<<'EOF' |
||
| 91 | Checking /base/path/changelog/duplicate-headers... |
||
| 92 | <warning>/base/path/changelog/duplicate-headers:3: Duplicate header "Type", previously seen on line 2. |
||
| 93 | Checking /base/path/changelog/good... |
||
| 94 | Checking /base/path/changelog/no-entry-is-patch... |
||
| 95 | Checking /base/path/changelog/no-entry-not-patch... |
||
| 96 | /base/path/changelog/no-entry-not-patch:5: Changelog entry may only be empty when Significance is "patch". |
||
| 97 | Checking /base/path/changelog/unknown-header... |
||
| 98 | <warning>/base/path/changelog/unknown-header:3: Unrecognized header "Bogus". |
||
| 99 | Checking /base/path/changelog/wrong-header-values... |
||
| 100 | /base/path/changelog/wrong-header-values:1: Significance must be "patch", "minor", or "major". |
||
| 101 | /base/path/changelog/wrong-header-values:2: Type must be must be "security", "added", "changed", "deprecated", "removed", or "fixed". |
||
| 102 | Checking /base/path/changelog/wrong-headers... |
||
| 103 | /base/path/changelog/wrong-headers: File does not contain a Significance header. |
||
| 104 | /base/path/changelog/wrong-headers: File does not contain a Type header. |
||
| 105 | <warning>/base/path/changelog/wrong-headers:1: Unrecognized header "Significants". |
||
| 106 | <warning>/base/path/changelog/wrong-headers:2: Unrecognized header "Typo". |
||
| 107 | Found 5 error(s) and 4 warning(s) |
||
| 108 | EOF |
||
| 109 | , |
||
| 110 | ), |
||
| 111 | 'Specific file' => array( |
||
| 112 | array( 'files' => array( 'changelog/good' ) ), |
||
| 113 | array(), |
||
| 114 | 0, |
||
| 115 | '', |
||
| 116 | ), |
||
| 117 | 'Only warnings' => array( |
||
| 118 | array( 'files' => array( 'changelog/unknown-header' ) ), |
||
| 119 | array(), |
||
| 120 | 1, |
||
| 121 | '<warning>changelog/unknown-header:3: Unrecognized header "Bogus".', |
||
| 122 | ), |
||
| 123 | 'Only warnings, non-strict' => array( |
||
| 124 | array( |
||
| 125 | '--no-strict' => true, |
||
| 126 | 'files' => array( 'changelog/unknown-header' ), |
||
| 127 | ), |
||
| 128 | array(), |
||
| 129 | 0, |
||
| 130 | '<warning>changelog/unknown-header:3: Unrecognized header "Bogus".', |
||
| 131 | ), |
||
| 132 | 'Multiple specific files' => array( |
||
| 133 | array( 'files' => array( 'changelog/.', 'changelog/..', 'changelog/.gitkeep' ) ), |
||
| 134 | array(), |
||
| 135 | 1, |
||
| 136 | <<<'EOF' |
||
| 137 | changelog/.: Expected a file, got dir. |
||
| 138 | changelog/..: Expected a file, got dir. |
||
| 139 | changelog/.gitkeep: File does not contain a Significance header. |
||
| 140 | changelog/.gitkeep: File does not contain a Type header. |
||
| 141 | EOF |
||
| 142 | , |
||
| 143 | ), |
||
| 144 | 'GH Actions output' => array( |
||
| 145 | array( '--gh-action' => true ), |
||
| 146 | array(), |
||
| 147 | 1, |
||
| 148 | <<<'EOF' |
||
| 149 | ::warning file=/base/path/changelog/duplicate-headers,line=3::Duplicate header "Type", previously seen on line 2. |
||
| 150 | ::error file=/base/path/changelog/no-entry-not-patch,line=5::Changelog entry may only be empty when Significance is "patch". |
||
| 151 | ::warning file=/base/path/changelog/unknown-header,line=3::Unrecognized header "Bogus". |
||
| 152 | ::error file=/base/path/changelog/wrong-header-values,line=1::Significance must be "patch", "minor", or "major". |
||
| 153 | ::error file=/base/path/changelog/wrong-header-values,line=2::Type must be must be "security", "added", "changed", "deprecated", "removed", or "fixed". |
||
| 154 | ::error file=/base/path/changelog/wrong-headers::File does not contain a Significance header. |
||
| 155 | ::error file=/base/path/changelog/wrong-headers::File does not contain a Type header. |
||
| 156 | ::warning file=/base/path/changelog/wrong-headers,line=1::Unrecognized header "Significants". |
||
| 157 | ::warning file=/base/path/changelog/wrong-headers,line=2::Unrecognized header "Typo". |
||
| 158 | EOF |
||
| 159 | , |
||
| 160 | ), |
||
| 161 | ); |
||
| 162 | } |
||
| 163 | |||
| 165 |