| Conditions | 1 |
| Paths | 1 |
| Total Lines | 72 |
| Code Lines | 48 |
| 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 |
||
| 25 | public function provideCasesForTestDetect(): iterable |
||
| 26 | { |
||
| 27 | yield 'Detect space indentation' => [ |
||
| 28 | $this->loadFixture('space.js'), |
||
| 29 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 30 | ' ', |
||
| 31 | ]; |
||
| 32 | |||
| 33 | yield 'Detect tab indentation' => [ |
||
| 34 | $this->loadFixture('tab.js'), |
||
| 35 | new Indentation(1, Indentation::TYPE_TAB), |
||
| 36 | "\t", |
||
| 37 | ]; |
||
| 38 | |||
| 39 | yield 'Detect multiple tabs' => [ |
||
| 40 | $this->loadFixture('tab-four.js'), |
||
| 41 | new Indentation(4, Indentation::TYPE_TAB), |
||
| 42 | "\t\t\t\t", |
||
| 43 | ]; |
||
| 44 | |||
| 45 | yield 'Detect equal tabs and spaces' => [ |
||
| 46 | $this->loadFixture('mixed-tab.js'), |
||
| 47 | new Indentation(1, Indentation::TYPE_TAB), |
||
| 48 | "\t", |
||
| 49 | ]; |
||
| 50 | |||
| 51 | yield 'Detect indent of a file with mostly spaces' => [ |
||
| 52 | $this->loadFixture('mixed-space.js'), |
||
| 53 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 54 | ' ', |
||
| 55 | ]; |
||
| 56 | |||
| 57 | yield 'Detect indent of a weirdly indented vendor prefixed CSS' => [ |
||
| 58 | $this->loadFixture('vendor-prefixed-css.css'), |
||
| 59 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 60 | ' ', |
||
| 61 | ]; |
||
| 62 | |||
| 63 | yield 'Return 0 when these is no indentation' => [ |
||
| 64 | '<ul></ul>', |
||
| 65 | new Indentation(0, Indentation::TYPE_UNKNOWN), |
||
| 66 | '', |
||
| 67 | ]; |
||
| 68 | |||
| 69 | yield 'Indentation for fifty-fifty indented files with spaces first' => [ |
||
| 70 | $this->loadFixture('fifty-fifty-space-first.js'), |
||
| 71 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 72 | ' ', |
||
| 73 | ]; |
||
| 74 | |||
| 75 | yield 'Indentation for fifty-fifty indented files with tabs first' => [ |
||
| 76 | $this->loadFixture('fifty-fifty-tab-first.js'), |
||
| 77 | new Indentation(1, Indentation::TYPE_TAB), |
||
| 78 | "\t", |
||
| 79 | ]; |
||
| 80 | |||
| 81 | yield 'Indentation for files with spaces and tabs last' => [ |
||
| 82 | $this->loadFixture('space-tab-last.js'), |
||
| 83 | new Indentation(1, Indentation::TYPE_TAB), |
||
| 84 | "\t", |
||
| 85 | ]; |
||
| 86 | |||
| 87 | yield 'Indentation of a file with single line comments' => [ |
||
| 88 | $this->loadFixture('single-space-ignore.js'), |
||
| 89 | new Indentation(4, Indentation::TYPE_SPACE), |
||
| 90 | ' ', |
||
| 91 | ]; |
||
| 92 | |||
| 93 | yield 'Indentation for files with single spaces only' => [ |
||
| 94 | $this->loadFixture('single-space-only.js'), |
||
| 95 | new Indentation(1, Indentation::TYPE_SPACE), |
||
| 96 | ' ', |
||
| 97 | ]; |
||
| 179 |