Conditions | 1 |
Paths | 1 |
Total Lines | 74 |
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 |
||
59 | public function itShouldExecuteAllTools() |
||
60 | { |
||
61 | $files = FilesCommittedStub::createAllFiles(); |
||
62 | $configurationDataResponse = ConfigurationDataResponseStub::createAllEnabled(); |
||
63 | |||
64 | $this->shouldWriteTitle(PreCommitToolHandler::TITLE, 'title'); |
||
65 | $this->shouldGetFilesCommitted($files); |
||
66 | $this->shouldHandleQuery(new ConfigurationDataFinder(), $configurationDataResponse); |
||
67 | $this->shouldHandleCommand( |
||
68 | new ComposerTool($files, $configurationDataResponse->getPreCommit()->getErrorMessage()) |
||
69 | ); |
||
70 | $this->shouldHandleCommand( |
||
71 | new JsonLintTool($files, $configurationDataResponse->getPreCommit()->getErrorMessage()) |
||
72 | ); |
||
73 | $this->shouldHandleQuery( |
||
74 | new PhpFilesExtractor($files), |
||
75 | PhpFilesResponseStub::create(FilesCommittedStub::createWithoutPhpFiles()) |
||
76 | ); |
||
77 | $this->shouldHandleCommand( |
||
78 | new PhpLintTool($files, $configurationDataResponse->getPreCommit()->getErrorMessage()) |
||
79 | ); |
||
80 | $this->shouldHandleCommand( |
||
81 | new PhpCsTool( |
||
82 | $files, |
||
83 | $configurationDataResponse->getPreCommit()->getPhpCs()->getPhpCsStandard(), |
||
84 | HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT, |
||
85 | $configurationDataResponse->getPreCommit()->getPhpCs()->getIgnore() |
||
86 | ) |
||
87 | ); |
||
88 | $this->shouldHandleCommand( |
||
89 | new PhpCsFixerTool( |
||
90 | $files, |
||
91 | $configurationDataResponse->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr0(), |
||
92 | $configurationDataResponse->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr1(), |
||
93 | $configurationDataResponse->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr2(), |
||
94 | $configurationDataResponse->getPreCommit()->getPhpCsFixer()->isPhpCsFixerSymfony(), |
||
95 | $configurationDataResponse->getPreCommit()->getPhpCsFixer()->getPhpCsFixerOptions(), |
||
96 | $configurationDataResponse->getPreCommit()->getErrorMessage() |
||
97 | ) |
||
98 | ); |
||
99 | $this->shouldHandleCommand( |
||
100 | new PhpMdTool( |
||
101 | $files, |
||
102 | $configurationDataResponse->getPreCommit()->getPhpMd()->getPhpMdOptions(), |
||
103 | $configurationDataResponse->getPreCommit()->getErrorMessage() |
||
104 | ) |
||
105 | ); |
||
106 | $this->shouldHandleCommand( |
||
107 | new PhpUnitTool( |
||
108 | $configurationDataResponse->getPreCommit()->getPhpUnit()->isPhpunitRandomMode(), |
||
109 | $configurationDataResponse->getPreCommit()->getPhpUnit()->getPhpunitOptions(), |
||
110 | $configurationDataResponse->getPreCommit()->getErrorMessage() |
||
111 | ) |
||
112 | ); |
||
113 | |||
114 | $this->shouldHandleCommand( |
||
115 | new StrictCoverage( |
||
116 | $configurationDataResponse->getPreCommit()->getPhpUnitStrictCoverage()->getMinimum(), |
||
117 | $configurationDataResponse->getPreCommit()->getErrorMessage() |
||
118 | ) |
||
119 | ); |
||
120 | |||
121 | $this->shouldHandleCommand( |
||
122 | new GuardCoverage( |
||
123 | $configurationDataResponse->getPreCommit()->getPhpUnitGuardCoverage()->getWarningMessage() |
||
124 | ) |
||
125 | ); |
||
126 | |||
127 | $this->shouldWriteLnOutput( |
||
128 | GoodJobLogoResponse::paint($configurationDataResponse->getPreCommit()->getRightMessage()) |
||
129 | ); |
||
130 | |||
131 | $this->preCommitToolCommandHandler->handle(new PreCommitTool()); |
||
132 | } |
||
133 | } |
||
134 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.