-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make php extensions configurable #83
Make php extensions configurable #83
Conversation
Good idea to configure extensions 👍 I'd rather move the configuration to .phpqa.yml. I'd like to keep CLI options as simple as possible. Option |
src/Options.php
Outdated
@@ -46,6 +49,7 @@ function ($dir) { | |||
$this->isOutputPrinted = $this->isSavedToFiles ? $options['verbose'] : true; | |||
$this->hasReport = $this->isSavedToFiles ? $options['report'] : false; | |||
$this->configDir = $options['config'] ? $options['config'] : getcwd(); | |||
$this->extensions = isset($options['extensions']) ? $options['extensions'] : 'php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isset
is not necessary when you update copy-pasted code in OptionsTest
It's complicated to retrieve default options from comment, so they are copy-pasted in the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to fix it. As I said in the comment, I would prefer configuration in .phpqa.yml
.
You can take a look at adding configuration to .phpqa.yml.
@zdenekdrahos done, you can review it now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make extensions configurable globally. Then only three lines should be changed in CodeAnalysisTasks
README.md
Outdated
@@ -139,6 +139,7 @@ For full documentation please visit [eko3alpha/docker-phpqa](https://hub.docker. | |||
| ~~`phpqa --analyzedDir ./`~~ | Deprecated in **v1.8** in favor of `--analyzedDirs` | | |||
| `phpqa --ignoredDirs build,vendor` | Ignore directories | | |||
| `phpqa --ignoredFiles RoboFile.php` | Ignore files | | |||
| `phpqa --extensions php,inc,module` | Run only on selected extensions (default: ``php`` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old comment, extensions
should be documented in advanced configuration
.phpqa.yml
Outdated
@@ -11,6 +11,8 @@ phpcs: | |||
checkstyle: checkstyle.xml | |||
# you can include custom reports (https://github.com/wikidi/codesniffer/blob/master/reports/wikidi/Summary.php#L39) | |||
# ./vendor/owner/package/src/MySummaryReport.php: phpcs-summary.html | |||
extensions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't define extensions for each tool, but only once (just like you had it in --extensions
).
extensions:
- php
src/CodeAnalysisTasks.php
Outdated
'standard' => $standard, | ||
$this->options->ignore->phpcs(), | ||
$this->options->getAnalyzedDirs(' '), | ||
); | ||
if (!empty($extensions)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of duplication in loading extensions. Extracting the code to Config might be a good idea.
$args = array(
'extensions' => $this->config->csv('extensions'),
);
It would be great to have tests that show behavior what happens, when extensions
is array, string, ...
I would ignore cases when extensions
are empty. It's required configuration, so we don't have to be too defensive.
@zdenekdrahos thanks for the review, you can see latest changes now. |
fix notice refactoring using .phpqa.yml move extensions to global namespace, add test, add logic to Config class to parse the array fix metrics
3afb72f
to
33a7974
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small fixes and it's ready to merge.
Good job 👍
src/CodeAnalysisTasks.php
Outdated
@@ -281,15 +281,17 @@ private function buildPhpcs(RunningTool $tool, array $installedStandards) | |||
|
|||
private function pdepend() | |||
{ | |||
return array( | |||
$opts = array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert a return. The temporary variable is useless.
tests/Config/ConfigTest.php
Outdated
@@ -56,6 +58,26 @@ public function testThrowExceptionWhenFileDoesNotExist() | |||
$config->path('phpcs.standard'); | |||
} | |||
|
|||
public function testConfigCsvArray() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One test is good enough if you move php,inc,module
to tests/Config/.phpqa.yml
.
- Array format is tested in default config.
- Hardcoding expected value in the test is fine (not perfect, but the test is more readable without parsing YAML).
I guess that removing YAML::parse
should help to pass Travis.ci
@@ -21,7 +21,7 @@ If you ever tried to get ignoring directories to work then you know what I mean. | |||
CLI tools are cool because you can analyze any directory or file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see only whitespace changes. Revert changes if you don't plan to document extensions
in advanced configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is has been automatically added by sublime, it is just a whitespace, i guess it quite safe to keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it is a safe change. But should it be a part of "Make PHP extensions configurable" commit, if nothing else is changed?
You can keep it, but add documentation for extensions
(newline after README.md#L201). Thanks
[extensions](https://github.com/EdgedesignCZ/phpqa/blob/master/.phpqa.yml) | File extensions | `[php]` | List of PHP file extensions |
@zdenekdrahos done |
@@ -56,6 +56,15 @@ public function testThrowExceptionWhenFileDoesNotExist() | |||
$config->path('phpcs.standard'); | |||
} | |||
|
|||
public function testConfigCsvString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please load tests/Config/.phpqa.yml
and remove tests/Config/data/custom-extensions-string/.phpqa.yml
.
$config->loadCustomConfig(__DIR__);
isNonEmptyString
assert is not necessary, equalTo
catches all types of invalid values. When the test fails I would rather see, that expected value is php,inc,module
instead of non-empty string. But that's a minor issue, you can leave it that way if you think it's better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -21,7 +21,7 @@ If you ever tried to get ignoring directories to work then you know what I mean. | |||
CLI tools are cool because you can analyze any directory or file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it is a safe change. But should it be a part of "Make PHP extensions configurable" commit, if nothing else is changed?
You can keep it, but add documentation for extensions
(newline after README.md#L201). Thanks
[extensions](https://github.com/EdgedesignCZ/phpqa/blob/master/.phpqa.yml) | File extensions | `[php]` | List of PHP file extensions |
@zdenekdrahos done 👍 |
I don't like squash. But I did it because of general commit message "code review" in history. I hope that's okay. |
No description provided.