mglaman / drupal-check

Check Drupal code for deprecations and discover bugs via static analysis
GNU General Public License v2.0
332 stars 67 forks source link

Inconsistent options behaviour #200

Open jacobfriis opened 3 years ago

jacobfriis commented 3 years ago

Using option analysis - or options analysis + deprecations - does not produce the expected check(s)

drupal-check:

Environment:

Options used Documentation Actual check(s)
(none) Vague, just 'check' deprecations
deprecations deprecations deprecations
analysis analysis analysis + deprecations
analysis + deprecations analysis + deprecations deprecations OR analysis + deprecations

Results of using analysis only are just counter to the expected, but at least consistent across different scenarios.

Results of analysis + deprecations depend on which directories|files you check. Cannot see any pattern. If I check ctools/src I (correctly) get analysis + deprecations. But if check some other - non-buggy quality code, ruined slightly to get failures - I only get deprecations. Unfortunately I do not have any published code to examplify.

Solution for now

Don't use analysis + deprecations, use analysis. And accept that there's no means of getting analysis only (which IMHO is pretty O.K.).

Examples - published code: drupal-check --analysis web/modules/contrib/ctools/src -> analysis + deprecations drupal-check --analysis --deprecations web/modules/contrib/ctools/src -> analysis + deprecations (correct)

Examples - unpublished code: drupal-check --analysis web/modules/custom/kk_cmpn_skin/src/KkCmpnSkinStylesheetGenerator.php 164 \Drupal calls should be avoided in classes, use dependency injection...(= analysis)
171 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0...(= deprecation)

drupal-check --analysis --deprecation web/modules/custom/kk_cmpn_skin/src/KkCmpnSkinStylesheetGenerator.php 171 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0...(= deprecation)

jacobfriis commented 3 years ago

Simple fix suggestion

The deprecations option is obsolete, because you always get deprecations check and deprecations=0 is BTW not supported.

Documentation:

Code: