Comments (10)
Fantastic, thanks for following up!
from wp-enforcer.
Hey @ahmadawais, thanks for the bug report. Let's see if we can triage this, shall we?
First, can you please verify the version of WP Enforcer you have installed? There have been a few releases in the last week, and I want to make sure it's not a problem that's already been solved.
If you run ./vendor/bin/phpcs
from the root of the repository, what output do you see? If the answer is "none", then the changes you made might not be egregious enough to trigger PHP_CodeSniffer. An easy way to check is inserting something like this:
if('foo' == 'bar'){
echo "baz";
}
That block should set off all sorts of whitespace alarms :)
Next, please verify that your Git repository has a "pre-commit" hook (e.g. .git/hooks/pre-commit). The contents of the file should look something like what's in the repository.
Finally, if PHP_CodeSniffer is finding a problem and the hook is in place but you're able to commit that bogus code, please try swapping out the contents of the pre-commit hook with the version from the release/0.4.0 branch, which was adjusted in #13. If that solves it, I'll get a point release pushed out this morning to expedite that fix.
Thanks again for the report, and I'll look forward to hearing back from you!
from wp-enforcer.
@stevegrunwell Now it seems to be working. I guess you fixed something.
Is that how it works? Does it not provide any info on what and where is the problem?
from wp-enforcer.
@ahmadawais what all does your gcma
alias do? The output should look something like this:
MacBook-Pro:wp-enforcer steve$ git add index.php
MacBook-Pro:wp-enforcer steve$ git commit -m "This file is riddled with errors"
Running PHP CodeSniffer...
FILE: /Users/steve/Sites/httpdocs/wp-enforcer/index.php
----------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
1 | ERROR | [ ] Missing file doc comment
3 | ERROR | [ ] Empty IF statement detected
3 | ERROR | [x] Expected 1 space after IF keyword; 0 found
3 | ERROR | [x] Space after opening control structure is required
3 | ERROR | [x] No space before opening parenthesis is prohibited
3 | ERROR | [x] No space after opening parenthesis is prohibited
3 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
3 | ERROR | [x] No space before closing parenthesis is prohibited
3 | ERROR | [x] Space between opening control structure and closing
| | parenthesis is required
5 | ERROR | [x] File must end with a newline character
----------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 102ms; Memory: 4.75Mb
Please fix coding standards errors before committing
from wp-enforcer.
@ahmadawais let's revisit this when 0.4.0 drops – there have been a lot of updates and hopefully we'll get closer to the expected behavior 😄
You can also update your composer.json to pull from the release/0.4.0
branch in the meantime.
from wp-enforcer.
@stevegrunwell gcma is git commit all. Check here.
I thought it would run for all files, shouldn't it?
from wp-enforcer.
In the very first release (0.1.0), the entire codebase was being run through PHP_CodeSniffer, which meant integrating WP Enforcer on an existing codebase could be a painful process. In #1 I adjusted this behavior so that only the files that are staged for commit are being checked; this way, if you're only touching functions.php in your commit you're not held liable for index.php, which you may or may not have ever touched.
You're still able to run PHP_CodeSniffer against the entire codebase, but I'd recommend doing that in a cleanup branch (see "Adding to an Existing Project").
Does that clarify things for you?
from wp-enforcer.
@ahmadawais ping for ^ ?
from wp-enforcer.
@stevegrunwell I'm going to try it next weekend, was busy with a WP Meetup.
from wp-enforcer.
Forgot to mention, it's working fine :)
from wp-enforcer.
Related Issues (20)
- Automated testing HOT 3
- Move master to a stable branch and promote develop to the in progress branch. HOT 2
- Move package changelog to CHANGELOG.md
- Rewrite for the PHP CLI? HOT 8
- Restrict hook to the changed code HOT 12
- Add support for JavaScript coding standards HOT 4
- Support custom PHPCS rulesets HOT 1
- Modifications to the phpcs.xml are picked up and won't allow a commit HOT 2
- No output from wp-enforcer setup script HOT 2
- FYI
- [docs] Install for --dev HOT 1
- Release 1.0.0 HOT 3
- [docs] Update installation instructions Re: Composer Commands HOT 1
- Require latest version of WPCS always HOT 7
- Respect config settings when creating pre-commit hook HOT 4
- Update README to signify where to add custom scripts
- Script overwrites installed coding standards HOT 2
- Checker prevents adding image files to repo HOT 1
- How about a github bot? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-enforcer.