codeclimate / codeclimate-phpcodesniffer

Code Climate Engine for PHP Code Sniffer
MIT License
28 stars 23 forks source link

configuration not being honored #8

Closed ablyler closed 9 years ago

ablyler commented 9 years ago

I'm trying to use a custom configuration via my .codeclimate.yml that is in the root of my repo that contains:

exclude_paths:
 - "/build"
 - "/doc_generator"
 - "/modules"
 - "/resource"
 - "/tests"
engines:
  phpcodesniffer:
    enabled: true
    config:
      - file_extensions: "php"
      - standard: ["/code/modules/code-standards/company/ruleset.xml"]
ratings:
  paths:
  - "**.php"

However, when I look at the running processes while running codeclimate analyze, I see:

 4327 ?        Ss     0:00  \_ /bin/sh /usr/src/app/bin/codeclimate-phpcodesniffer
 4333 ?        S      0:00      \_ php /usr/src/app/bin/../engine.php
 4334 ?        S      0:00          \_ sh -c ./vendor/bin/phpcs --report=json --ignore= --standard=PSR1,PSR2 /code
 4335 ?        R      0:01              \_ php ./vendor/bin/phpcs --report=json --ignore= --standard=PSR1,PSR2 /code
ablyler commented 9 years ago

Also, this might be a hint:

$ codeclimate validate-config
WARNING in engines: unexpected key "config", dropping
pbrisbin commented 9 years ago

Sorry about this! We recently made our config parser more strict and accidentally made it reject this valid key. We'll do our best to get that fixed soon.

gdiggs commented 9 years ago

@ablyler

Hey! I just pushed some changes that should resolve this issue. Here's what you need to do:

  1. Update the codeclimate CLI. If you're using homebrew on OS X, you can do this with brew update && brew upgrade codeclimate.
  2. Update your config file to be the following:

    exclude_paths:
    - "build/**/*"
    - "doc_generator/**/*"
    - "modules/**/*"
    - "resource/**/*"
    - "tests/**/*"
    engines:
     phpcodesniffer:
       enabled: true
       config:
         file_extensions: "php"
         standard: "/code/modules/code-standards/company/ruleset.xml"
    ratings:
     paths:
     - "**/*.php"

    I changed a few things here:

    • Your exclude paths were absolute instead of relative. These new globs will exclude all files in those directories and their subdirectories
    • I updated the phpcodesniffer config. Our README was actually wrong on this one and I've updated it there as well.
    • Applied a similar glob fix to the ratings paths.
  3. Re-run codeclimate analyze. You should have the correct config now.

If this doesn't work for you, let me know and I can help debug more!

ablyler commented 9 years ago

@GordonDiggs thanks, I think we are getting closer! Is this normal?

 2693 ?        Ss     0:00  \_ /bin/sh /usr/src/app/bin/codeclimate-phpcodesniffer
 2701 ?        S      0:00      \_ php /usr/src/app/bin/../engine.php
 2702 ?        S      0:00          \_ sh -c ./vendor/bin/phpcs --report=json --extensions=php --ignore= --standard=/code/modules/code-standards/company/ruleset.xml /code
 2703 ?        R      1:41              \_ php ./vendor/bin/phpcs --report=json --extensions=php --ignore= --standard=/code/modules/code-standards/company/ruleset.xml /code

Notice the empty ignore arg. Should that contain the exclude paths?

ablyler commented 9 years ago

Also, the output of codeclimate analyze is:

Starting analysis
Running phpcodesniffer: Done!

Analysis complete! Found 0 issues.

But when I run phpcs by hand there are a bunch of outstanding issues.

gdiggs commented 9 years ago

@ablyler I think I can help with that! Will you email gordon [at] codeclimate.com and we can talk there (better than the public github comments)?

gdiggs commented 9 years ago

@ablyler updated the email in my last comment