magento / magento-coding-standard

Magento Coding Standard
Open Software License 3.0
347 stars 153 forks source link

Do not allow slash the beginning of the class pass in use #165

Open ihor-sviziev opened 4 years ago

ihor-sviziev commented 4 years ago

use section does not actually need \ at the beginning of the classpath (leading backslash). Let’s enforce it by static tests to prevent appearing such cases in future

Originally posted by @ihor-sviziev in https://github.com/magento/magento2/pull/26129#issuecomment-567404199

konarshankar07 commented 4 years ago

Hello @ihor-sviziev , What should be the severity and type of this rule?

konarshankar07 commented 4 years ago

After further investigation, I found that this rule is a part of PSR-12. Please check PSR12.Files.ImportStatement. Let me know your thoughts Thanks

ihor-sviziev commented 4 years ago

@lenaorobei could you defined which severity should be set for this rule? As for me - should be 6, similar to https://github.com/magento/magento-coding-standard/blob/199057a8ca960e0bb191ec8fd7a409fbd91c8a51/Magento2/ruleset.xml#L457-L460

@konarshankar07 I think it's good idea to re-use rules from PSR12

lenaorobei commented 4 years ago

Agree with @ihor-sviziev, severity 6 is that we use for code style.

And yes, it would be nice to reuse PSR12.

Adding @coderimus since he is working on PSR12 update.

ihor-sviziev commented 4 years ago

@konarshankar07 do you have any updates? Do you have some working version?

konarshankar07 commented 4 years ago

Hello @ihor-sviziev ... I'm waiting for the PSR12 update cause there is already a rule for this in PSR-12. I'm not sure if we have updated the PSR12 or not Thanks

hostep commented 3 years ago

Not sure if this is helpful but PSR-12 support just made it in v2.18.0 of friendsofphp/php-cs-fixer (also not sure if this comment makes sense in this repo since the magento2 repo makes use of it but the coding-standard not, which is odd ...)