Coder Social home page Coder Social logo

Not working! about wp-enforcer HOT 10 CLOSED

stevegrunwell avatar stevegrunwell commented on September 22, 2024
Not working!

from wp-enforcer.

Comments (10)

stevegrunwell avatar stevegrunwell commented on September 22, 2024 1

Fantastic, thanks for following up!

from wp-enforcer.

stevegrunwell avatar stevegrunwell commented on September 22, 2024

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.

ahmadawais avatar ahmadawais commented on September 22, 2024

@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?
image

from wp-enforcer.

stevegrunwell avatar stevegrunwell commented on September 22, 2024

@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.

stevegrunwell avatar stevegrunwell commented on September 22, 2024

@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.

ahmadawais avatar ahmadawais commented on September 22, 2024

@stevegrunwell gcma is git commit all. Check here.

I thought it would run for all files, shouldn't it?

from wp-enforcer.

stevegrunwell avatar stevegrunwell commented on September 22, 2024

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.

stevegrunwell avatar stevegrunwell commented on September 22, 2024

@ahmadawais ping for ^ ?

from wp-enforcer.

ahmadawais avatar ahmadawais commented on September 22, 2024

@stevegrunwell I'm going to try it next weekend, was busy with a WP Meetup.

from wp-enforcer.

ahmadawais avatar ahmadawais commented on September 22, 2024

Forgot to mention, it's working fine :)

from wp-enforcer.

Related Issues (20)

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.