overtrue / phplint

:bug: A tool that can speed up linting of php files by running several lint processes at once.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't disable cache in file

vlakarados opened this issue · comments

Cache can't be disabled in the file because of usage of $input->getOption('no-cache') instead of merged $options['no-cache'] in LintCommand::execute()

Hello @vlakarados

Can you precise which version you used (native php installed by composer OR docker or PHAR) and version number ?

I cannot reproduce your issue

Hi @llaville,
I use composer version, here's entry from .lock file:

"name": "overtrue/phplint",
"version": "5.3.0",

If source code you check is open-source, could you provide a link to repository.
If you can also provide a version of your .phplint-cache file

Don't forget also to provide contents of your .phplint.yml config file

Just did this with fresh installation, PHP 8.1 on Ubuntu, here's history output:

3905  composer init
 3908  composer require overtrue/phplint
 3909  cp ../../projects/phpchecks/config/lint.yml .
 3911  cat lint.yml
 3915  ./vendor/bin/phplint -c lint.yml -vvv .
 3917  ./vendor/bin/phplint -c lint.yml -vvv .
 3920  history | tail -n10

$ cat lint.yml

path: ./target
jobs: 10
extensions:
  - php
exclude:
  - vendor/phpoffice
warning: true
memory_limit: -1
cache: No

First run:

...
Time: < 1 sec   Memory: 4.0 MiB Cache: No
OK! (Files: 231, Success: 231)
 

Second run:


$ ./vendor/bin/phplint -c lint.yml -vvv .
phplint 5.3 by overtrue and contributors.

Loaded config from "lint.yml"

Options: {"jobs":10,"path":["."],"exclude":["vendor\/phpoffice"],"extensions":["php"],"warning":true,"memory_limit":-1,"cache":"No","configuration":"lint.yml","verbose":true}
Time: < 1 sec   Memory: 4.0 MiB Cache: Yes
OK! (Files: 231, Success: 231)

Ok I see the problem now !
Thanks to provide all these informations.

@overtrue As it seems confusion between options is possible, I've re-structured code to add a new component named ConfigResolver. It's goal is to validate all options (either from command line or from a config file).

I'll propose in next minutes a PR to solve this issue for branch 8.0 (and if you're agree, I'll apply it to other branches)

Just do it! I trust you 👍

I'll also renamed memory_limit option to memory-limit to always use the same syntax (dash as word separator, rather than underscore)

And If we forgot something, the symfony/options-resolver will help us :)

For example:

  [Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException]
  The option "memory-limit" does not exist. Defined options are: "cache", "configuration", "exclude", "extensions", "jobs", "no-cache", "path", "warning"
  .

Code is available on branch fix-163 : help to check if I've missed something or introduced new regression is welcome ! @overtrue and @vlakarados

To avoid confusion :

  • cache in YAML config file identify the file to save cache results
  • no-cache in YAML config file tell if you want to always bypass cache file as console --no-cache option.

Already found some regressions about format (json | xml) I'm on it !

PS: fixed by commit 4966bbb

All regressions seems to be fixed now. @vlakarados if it's ok for you, we may think to push new releases tomorrow.

All good, it's no rush for me!

FYI: Branch 8.0 for umpcoming version 4.4 is now stable.
I'll apply same fixes on other branches, and push new releases.

Available in latest releases 3.3.1, 4.4.0, 5.4.1 and 6.0.3