Skip to content

Update PHP_CodeSniffer #328

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 6 commits into from
Jun 24, 2017
Merged

Update PHP_CodeSniffer #328

merged 6 commits into from
Jun 24, 2017

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Jun 23, 2017

I've added a few commands to the package.json file.

npm test - shortcut for tests
npm run test:coverage - for travis
npm run lint - Lints src and test folders
npm run lint:fix - Automatically Lints files

I've also forced travis to lint files.

CONTIBUTING.md has been updated

I have phpcs already installed on my text editor so I thought it would be nice to have in this project.

@codecov
Copy link

codecov bot commented Jun 23, 2017

Codecov Report

Merging #328 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #328      +/-   ##
==========================================
+ Coverage   98.04%   98.05%   +<.01%     
==========================================
  Files          35       35              
  Lines        2708     2718      +10     
==========================================
+ Hits         2655     2665      +10     
  Misses         53       53
Impacted Files Coverage Δ
src/Parse/ParseInstallation.php 100% <ø> (ø) ⬆️
src/Parse/ParseConfig.php 100% <ø> (ø) ⬆️
src/Parse/ParsePushStatus.php 100% <ø> (ø) ⬆️
src/Parse/HttpClients/ParseCurl.php 100% <100%> (ø) ⬆️
src/Parse/ParseFile.php 100% <100%> (ø) ⬆️
src/Parse/Internal/RemoveOperation.php 100% <100%> (ø) ⬆️
src/Parse/HttpClients/ParseStream.php 100% <100%> (ø) ⬆️
src/Parse/ParseClient.php 98.93% <100%> (ø) ⬆️
src/Parse/HttpClients/ParseStreamHttpClient.php 100% <100%> (ø) ⬆️
src/Parse/ParseRole.php 100% <100%> (ø) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20dd7a5...3b23db4. Read the comment docs.

@dplewis
Copy link
Member Author

dplewis commented Jun 23, 2017

@montymxb for future reference if you want to ignore lines for linter

// @codingStandardsIgnoreStart
echo 'ignore';
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreLine
echo 'ignore line' // @codingStandardsIgnoreLine

If you want to ignore lines to improve coverage

// @codeCoverageIgnoreStart
echo 'coverage';
// @codeCoverageIgnoreEnd
exit; // @codeCoverageIgnore

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

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

Whew....that's a lot of linted code...Ok, so everything checks out except most of those ignores that should be corrected. If you can take care of that I'll check out those changes and we should be good!

CONTRIBUTING.md Outdated
@@ -63,7 +63,15 @@ Alternately you can configure a compatible test server as follows:

You should now be able to execute the tests, from project root folder:

./vendor/bin/phpunit
`npm test`
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I would like to retain both ways of running tests in the documentation. In some cases local users may want to use an alternate version of php besides the default to run phpunit under. Via npm test there's really no way to do this.

You can add it after the npm marks here, since those are a bit more manageable and most will be ready to go that route (I would imagine at least). Something like You may also run tests directly using phpunit as follows. As for the lint and lint:fix don't worry about adding their equivalents, the npm ones will be fine and are (personally) easier to remember than their equivalents.

CONTRIBUTING.md Outdated

Make sure your code is linted with phpcs (PSR-2 Coding Style)

`npm run lint`
Copy link
Contributor

Choose a reason for hiding this comment

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

If you take a look here your code block comment is rendering with the grave ticks still. Same for npm test above and npm run lint:fix below.

I like the ability to lint via npm though, this is a lot more concise than calling phpunit directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

nice catch

CONTRIBUTING.md Outdated

You can automatically fix lint errors with phpcbf

`npm run lint:fix`
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, nice to have an alias in a sense.

I'm guessing all these changes are from the auto linting? We haven't been enforcing strong linting for some time it would appear. I'll just glance over all these to make sure they're acceptable; I'm expecting they are however.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah auto linting is my friend on this one

@@ -124,6 +124,7 @@
*
* @throws Exception
*/
//@codingStandardsIgnoreLine
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious what was the error phpcs was bringing up here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nvm I took a look at it myself. Considering that this line is rather long I would suggest breaking it down like ParseClient::_request. Then just make sure to remove the ignore above it.

@@ -807,6 +806,7 @@ public static function destroyAll(array $objects, $useMasterKey = false)
*/
private static function destroyBatch(array $objects, $useMasterKey = false)
{
//@codingStandardsIgnoreStart
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here, you can break down the offending string being set on path. Looking it you can probably break it down fairly easily like so. Just be sure to remove the ignore start/end once done.

$data[] = [
	'method' => 'DELETE',
	'path'   =>
		'/'.ParseClient::getMountPath().
		'classes/'.$object->getClassName().
		'/'.$object->getObjectId(),
];

$auth_token,
$auth_token_secret)
{
$auth_token, //@codingStandardsIgnoreLine
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine for an ignore, but if you can put it between like so

$consumer_secret = null,
//@codingStandardsIgnoreLine
$auth_token,

it should still work and won't be trailing after $auth_token instead.

@@ -246,10 +247,11 @@ public static function loginWithAnonymous()
* @link https://en.wikipedia.org/wiki/Universally_unique_identifier
*/
$uuid_parts = str_split(md5(mt_rand()), 4);
//@codingStandardsIgnoreStart
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, please break the offending line down and remove the ignores.

@@ -338,10 +342,11 @@ public function linkWithTwitter(
$screen_name,
$consumer_key,
$consumer_secret = null,
$auth_token,
$auth_token, //@codingStandardsIgnoreLine
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as the other twitter one, just bump it between the two rather than right after one of the args.

@montymxb
Copy link
Contributor

I don't think we'll ever be needing to ignore lines to bump up our coverage, besides I wouldn't really have any desire in artificially inflating that number.

According to codecov's report we're already the top dog at just under 98% total coverage as is 👍 .

@flovilmart
Copy link
Contributor

Yeah, don't ignore the not-covered lines it makes it impossible to improve correctly the coverage or identifying potential issues.

@dplewis
Copy link
Member Author

dplewis commented Jun 23, 2017

@montymxb thanks for the feedback. The changes have been made

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

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

Alright just a couple nit picky things. Everything else looks good to me though. And with the tests looking okay I think we're ready to merge this in once these final changes have been made.

CONTRIBUTING.md Outdated

You may also run tests directly using phpunit as follows:

npm test

Make sure your code is linted with phpcs (PSR-2 Coding Style)
Copy link
Contributor

Choose a reason for hiding this comment

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

I figure just so people aren't wondering about why we would enforce PSR-2 we should make this a link. You can use http://www.php-fig.org/psr/psr-2/, which is the style guide published by the framework interop group.

Making it...
Make sure your code is linted with phpcs (PSR-2 Coding Style)

Copy link
Contributor

Choose a reason for hiding this comment

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

And if we can add a colon after this statement, same as the line above it:

You may also run tests directly using phpunit as follows:

CONTRIBUTING.md Outdated

Make sure your code is linted with phpcs (PSR-2 Coding Style)

`npm run lint`
npm run lint

You can automatically fix lint errors with phpcbf
Copy link
Contributor

Choose a reason for hiding this comment

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

And if we can add a colon here at the end of this statement too that would be fantastic.

@montymxb
Copy link
Contributor

Cool, thanks! Just waiting on one of the CI jobs to rerun real quick.

@montymxb montymxb merged commit ee8d556 into parse-community:master Jun 24, 2017
@dplewis dplewis deleted the lint branch June 24, 2017 03:25
dplewis added a commit to dplewis/parse-php-sdk that referenced this pull request Jul 12, 2017
* Add lint

* update travis

* coding style

* add coverage to gitignore

* removed ignore lines

* nit
montymxb pushed a commit that referenced this pull request Jul 12, 2017
* Add ParsePolygon Type and polygonContains query

* test class fix

* error handling for polygon

* Update PHP_CodeSniffer (#328)

* Add lint

* update travis

* coding style

* add coverage to gitignore

* removed ignore lines

* nit

* Updated parse-php-sdk to version 1.2.9

* Corrects and updates phpdoc references/errors (#329)

* Corrects and updates phpdoc references/errors

* Lint fixes

* Added 'Getting Started' to README.md

Adds a **Getting Started** section to README.md to direct newcomers to the [official guide](http://docs.parseplatform.org/php/guide/) and [API reference](http://parseplatform.org/parse-php-sdk/namespaces/Parse.html).

* Remove Default API (#332)

* Removed default api and added appropriate checking

* lint

* Pages autodeploy and phpdoc style enforcing (#335)

* Added 'document-check' to add phpdoc checking during tests and added deploy for api ref on gh-pages

* Wrapping filename in quotes

* Moved bash out of package.json

* Unescaping strings

* Testing missing block comment

* Fixing lint exception to expose phpdoc style issue

* Restored class summary

* removed comment

* fix documentation

* Pinned jms/serializer to 1.7.1 (#336)

* Pinned jms/serializer to 1.7.1

* Checking to update jms/serializer to 1.8.0 ONLY on php 5.4 for travis-ci

* Added comment, and added graphviz for class diagrams in generated api docs
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.

3 participants