The Wayback Machine - https://web.archive.org/web/20201117214534/https://github.com/phpmd/phpmd/issues/812
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce own rules to the codebase #812

Open
Morgy93 opened this issue Aug 3, 2020 · 1 comment
Open

Enforce own rules to the codebase #812

Morgy93 opened this issue Aug 3, 2020 · 1 comment

Comments

@Morgy93
Copy link

@Morgy93 Morgy93 commented Aug 3, 2020

Description

Hello,

it would be awesome if you could enforce your own rules to your own code, because people could then have a look at it for reference.
I just opened up the very first file I came across and immediately saw multiple rule violations:

https://phpmd.org/rules/cleancode.html#elseexpression
https://github.com/phpmd/phpmd/blob/master/src/bin/phpmd#L25
https://github.com/phpmd/phpmd/blob/master/src/bin/phpmd#L48

https://phpmd.org/rules/design.html#exitexpression
https://github.com/phpmd/phpmd/blob/master/src/bin/phpmd#L55
https://github.com/phpmd/phpmd/blob/master/src/bin/phpmd#L61

"If they don't care about their rules, why should I" - would probably be the first thought for many. 😄

Checks before submitting

  • Be sure that there isn't already an issue about this. See: Issues list
  • Be sure that there isn't already a pull request about this. See: Pull requests
  • Tell if you have the option to provide the code for this proposal.
  • This issue is about 1 feature proposal and nothing more.
  • The issue has a descriptive title. For example: "Add JSON render option".
@tvbeek
Copy link
Member

@tvbeek tvbeek commented Aug 3, 2020

@Morgy93 thanks for your issue.

There are indeed parts of the code that need to be changed to follow the rules. There are only some things to think about.

The rules aren't holy (else there shouldn't be a way to suppress them see: https://phpmd.org/documentation/suppress-warnings.html )

And there are situations where there a rule isn't possible to use without loosing functionality. Like the exit expressions that you point out. We could return 1; instead of exit(1); but that result in a different exit code and doesn't make it clear for a pipeline that it failed.

Feel free to create a PR fixing (some off) the parts where PHPMD doesn't follow its own rules. Or annotate the suppressing of the places where it is impossible to follow the rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.