Skip to content

Add style and static analyzer checks #301

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

Merged
merged 2 commits into from
Jan 11, 2018
Merged

Add style and static analyzer checks #301

merged 2 commits into from
Jan 11, 2018

Conversation

dzubchik
Copy link
Contributor

I've added fixes after analyzer, so please review them. I propose to choose rules from the list.

composer.json Outdated
"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^5.7",
"friendsofphp/php-cs-fixer": "^2.8",
"phpstan/phpstan": "^0.8.5"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove from dependencies until 7.0. Require global on CI

@dzubchik dzubchik changed the title [wip] add style and static analyzer checks add style and static analyzer checks Nov 30, 2017
@dzubchik dzubchik changed the title add style and static analyzer checks Add style and static analyzer checks Nov 30, 2017
@dzubchik
Copy link
Contributor Author

@andig , @kelunik , @marcj ping

@dzubchik dzubchik force-pushed the master branch 2 times, most recently from 30991fc to 1d018a9 Compare November 30, 2017 21:30
.phpstan.neon Outdated
excludes_analyse:
- %rootDir%/vendor/*
ignoreErrors:
- '#Result of method React\\Socket\\ServerInterface::close\(\) \(void\) is used#'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.travis.yml Outdated
@@ -1,3 +1,4 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ yamllint .travis.yml 
  1:1       warning  missing document start "---"  (document-start)
  14:81     error    line too long (189 > 80 characters)  (line-length)
  16:81     error    line too long (161 > 80 characters)  (line-length)
  17:81     error    line too long (254 > 80 characters)  (line-length)
  31:81     error    line too long (95 > 80 characters)  (line-length)

Remove?

.travis.yml Outdated
- rm composer.lock && rm -rf vendor
- composer install
- ./vendor/bin/phpunit

# composer can not install httpkernel-adapter with default stability
- composer config minimum-stability dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? We currently are on dev stability?

Client.php Outdated
@@ -4,8 +4,9 @@

use React\EventLoop\Factory;
use React\EventLoop\LoopInterface;
use React\Socket\UnixConnector;
use React\Promise\ExtendedPromiseInterface;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be PromiseInterface?

Client.php Outdated
@@ -27,7 +28,7 @@ public function __construct()
}

/**
* @return ConnectionInterface
* @return ExtendedPromiseInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be PromiseInterface?

@andig
Copy link
Contributor

andig commented Dec 3, 2017

I'd suggest getting this in right after #305 which already has a number of clean-ups.

@dzubchik dzubchik force-pushed the master branch 2 times, most recently from 6a3f886 to b3f9cba Compare December 13, 2017 20:23
@dzubchik dzubchik changed the title Add style and static analyzer checks [wip] Add style and static analyzer checks Dec 13, 2017
@dzubchik dzubchik force-pushed the master branch 2 times, most recently from b8f72c2 to 5fd8569 Compare December 13, 2017 20:58
@dzubchik dzubchik changed the title [wip] Add style and static analyzer checks Add style and static analyzer checks Dec 13, 2017
@dzubchik
Copy link
Contributor Author

@andig , @kelunik any comments?

@dzubchik
Copy link
Contributor Author

One more note: I have not added phpstan and php-cs-fixer to require-dev section because of php5.6. So, now you should have globally installed phpstan && php-cs-fixer.

@dzubchik
Copy link
Contributor Author

Any feedback?

@andig
Copy link
Contributor

andig commented Dec 19, 2017

Any feedback?

Sorry for the troubles. Could you please recheck? I still see the odd ExtendedPromiseInterface which need be removed?

@dzubchik dzubchik force-pushed the master branch 2 times, most recently from c7e4d92 to 1e78682 Compare December 20, 2017 15:52
@dzubchik
Copy link
Contributor Author

I've updated PR according to latest refactoring with slaves. Removed ExtendedPromiseInterface, because that part of the code has been removed.

@andig andig mentioned this pull request Dec 22, 2017
15 tasks
@dzubchik
Copy link
Contributor Author

dzubchik commented Jan 9, 2018

@andig , @marcj what wrong with this PR? It seemed that this PR is important according to 2 new PR opened for last day. Are any chances for it to be merged after one more rebase?

@andig
Copy link
Contributor

andig commented Jan 9, 2018

@dzubchik sorry for the delay- I didn't notice you had pushed once more.

I'm happy with all the changes except for the ci updates. It seems we have 3 code analysis tools running now and I'm lost on how to of which one to integrate (and have it hint or fail). Funny enough they also come up with different findings :)

I'd propose to merge the code updates but not change the CI pipeline for now? And then lets merge them asap to not get bit-rotten again.

@szepeviktor
Copy link
Contributor

Funny enough they also come up with different findings :)

This is a good reason to keep all of them around!

@szepeviktor
Copy link
Contributor

It seems we have 3 code analysis tools running now

And two of them are called "phpstan" 😃

@dzubchik
Copy link
Contributor Author

@andig PR is updated. Let me know if something should be changed.

@andig
Copy link
Contributor

andig commented Jan 10, 2018

@dzubchik as I wrote- I like the findings but

I'd propose to merge the code updates but not change the CI pipeline for now?

Could you remove the phpstan config and travis.yml changes?

@dzubchik
Copy link
Contributor Author

dzubchik commented Jan 11, 2018

@andig , phpstan.neon config can not be removed because it allows to ignore these:

 ------ ------------------------------------------------------------------------ 
  Line   src/ProcessSlave.php                                                    
 ------ ------------------------------------------------------------------------ 
  200    Result of method React\Socket\ServerInterface::close() (void) is used.  
 ------ ------------------------------------------------------------------------ 
  Line   src/ProcessManager.php                                                  
 ------ ------------------------------------------------------------------------ 
  218    Result of method React\Socket\ServerInterface::close() (void) is used.  
  221    Result of method React\Socket\ServerInterface::close() (void) is used.

These "errors" appeared because of "@" usage.

And the .travis.yml must have these checks otherwise it does not make sense. If we do not run each build this, we should not add these tools at all. And now phpstan and php-code-fixer are not in "require-dev" section because of php5.6. After upgrading we can add them to "composer.json" and developer will have these tools during development. Now, he should install phpstan and php-cs-fixer globally to use them.

# Static analyzer check
- if [ $TRAVIS_PHP_VERSION = '7.1' ]; then composer require "phpstan/phpstan:^0.9" && ./vendor/bin/phpstan analyze -c .phpstan.neon --level=2 --no-progress src;fi
# Check the code style
- if [ $TRAVIS_PHP_VERSION = '7.1' ]; then IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS; fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added to run static analyze checks and code style checks, so code with wrong style-guide, some misspelling, incorrect return types and phpdocs will not be merged to master branch. And it should be run once, not for each php version. The instruction for php-cs-fixer was taken from documentation.

@andig andig merged commit 3328fca into php-pm:master Jan 11, 2018
@andig
Copy link
Contributor

andig commented Jan 11, 2018

Great, much appreciated and thank you for your patience!

@andig andig mentioned this pull request Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants