Coder Social home page Coder Social logo

phpcs-diff's People

Contributors

olivertappin avatar totalwipeout avatar zen1t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

phpcs-diff's Issues

PhpcsDiff doesn't return a non-zero exit code when violations are reported

Example from a Travis CI console output:

$ if [ ! -z "$TRAVIS_PULL_REQUEST_BRANCH" ]; then phpcs-diff $TRAVIS_BRANCH; else echo "This test does not derive from a pull-request. Unable to run phpcs-diff."; fi;
########## START OF PHPCS CHECK ##########
module/MyModule/src/MyClass/Something.php
 - Line 179 (WARNING) Line exceeds 120 characters; contains 184 characters
 - Line 202 (WARNING) Line exceeds 120 characters; contains 179 characters
 - Line 237 (WARNING) Line exceeds 120 characters; contains 155 characters
 - Line 251 (ERROR) Multi-line function call not indented correctly; expected 32 spaces but found 40
 - Line 251 (ERROR) Closing parenthesis of a multi-line function call must be on a line by itself
########### END OF PHPCS CHECK ###########
The command "if [ ! -z "$TRAVIS_PULL_REQUEST_BRANCH" ]; then phpcs-diff $TRAVIS_BRANCH; else echo "This test does not derive from a pull-request. Unable to run phpcs-diff."; fi;" exited with 0.

The issue here is https://github.com/olivertappin/phpcs-diff/blob/master/src/PhpcsDiff.php#L187 does not return a non-zero exit code when showing the violations.

An alternative (in the mean time) could be to validate the success response:

phpcs-diff $TRAVIS_BRANCH | (! grep -v 'No violations to report.' )

Show raw phpcs errors when executable could not run

When encountering an error via the phpcs executable, currently the tool returns:

Unable to run phpcs executable.

Which is executed here: https://github.com/olivertappin/phpcs-diff/blob/master/src/PhpcsDiff.php#L144

Whereas the real error could be something like:

ERROR: the "ruleset.xml" coding standard is not installed. The installed coding standards are PEAR, MySource, Squiz, PSR2, Zend, PSR12 and PSR1

Which can be difficult to find.

The suggestion here would be to change this functionality and have the raw error returned to the user, so they're able to see what's going on.

Unable to run grep command in Alpine

grep: unrecognized option: P
BusyBox v1.31.1 () multi-call binary.
Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...
Search for PATTERN in FILEs (or stdin)
	-H	Add 'filename:' prefix
	-h	Do not add 'filename:' prefix
	-n	Add 'line_no:' prefix
	-l	Show only names of files that match
	-L	Show only names of files that don't match
	-c	Show only count of matching lines
	-o	Show only the matching part of line
	-q	Quiet. Return 0 if PATTERN is found, 1 otherwise
	-v	Select non-matching lines
	-s	Suppress open and read errors
	-r	Recurse
	-i	Ignore case
	-w	Match whole words only
	-x	Match whole lines only
	-F	PATTERN is a literal (not regexp)
	-E	PATTERN is an extended regexp
	-m N	Match up to N times per file
	-A N	Print N lines of trailing context
	-B N	Print N lines of leading context
	-C N	Same as '-A N -B N'
	-e PTRN	Pattern to match
	-f FILE	Read pattern from file
No violations to report.

Git diff regular expression not filtering properly in all instances

It appears in some jobs, the regular expression to match the changed lines is not selecting all the necessary parts:

travis@travis-job-f6e74a8f-d328-4130-bc86-dbda51998fe9:~/build/my-app$ git diff -U0 origin/my-branch 4e43fa1b5e8eb31455530a8d55f6d72877260342 /home/travis/build/my-app/MyClass.php | grep -E '@@ -[0-9]+(?:,[0-9]+)? \+([0-9]+)(,([0-9]+))? @@'

If we remove the second part of the regular expression (before the space), it matches:

travis@travis-job-f6e74a8f-d328-4130-bc86-dbda51998fe9:~/build/my-app$ git diff -U0 origin/my-branch 4e43fa1b5e8eb31455530a8d55f6d72877260342 /home/travis/build/my-app/MyClass.php | grep -E '@@ -[0-9]+(:,[0-9]+)?,'
@@ -103,0 +104 @@ class MyClass
@@ -106,0 +108,5 @@ class MyClass
@@ -898,0 +905,2 @@ class MyClass
@@ -902,3 +910,16 @@ class MyClass
@@ -906,2 +927,2 @@ class MyClass
@@ -910,0 +932,32 @@ class MyClass

Which suggests what we think is a space, isn't actually a space after all:

@@ -103,0 +104 @@ class MyClass
         ^ --- here

The regular expression defined here: https://github.com/olivertappin/phpcs-diff/blob/master/src/PhpcsDiff.php#L251 needs to be updated to match these instances.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.