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

Discuss: Add, change or remove rules #1

Open
6 tasks
dalepgrant opened this issue Jun 23, 2021 · 1 comment
Open
6 tasks

Discuss: Add, change or remove rules #1

dalepgrant opened this issue Jun 23, 2021 · 1 comment

Comments

@dalepgrant
Copy link
Member

dalepgrant commented Jun 23, 2021

Why

Creating an issue to track rules that would be useful to add, change or remove in our existing CS. Adding some could help with automagic code formatting, whereas changing or removing could help with annoying ones that we frequently ignore anyway.

To add

  • Warning if a new function is over 100 lines long, it can probably be refactored/split up. Error at 500?
  • Warning if a new file (handmade, not generated) is over 500 lines long. Error at 1000?
  • Warning if we are chaining foreach loops or looping over the same variable twice, might be a better way to do things.
  • Warning if we are accessing the property of an object or array without a defensive check, i.e. if ($array[0] != null && count($array[0]) > 1)

To Change/Remove

  • Squiz.Classes.ValidClassName.NotCamelCaps Do we actually care? WP uses snake_case but "Class names should use capitalized words separated by underscores. Any acronyms should be all upper case" e.g. Walker_Category, WP_Post & WP_HTTP.
  • WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase See Squiz.Classes.ValidClassName.NotCamelCaps above.
@paulbrzeski
Copy link

Re: Squiz.Classes.ValidClassName.NotCamelCaps, I've never found this to be that big a problem for readability. Comments and the keywords used in naming variables and functions seem to be more important for comprehension.

A few ideas off the top of my head:

  • Warning if a new function is over 100 lines long, it can probably be refactored/split up. Error at 500?
  • Warning if a new file (handmade, not generated) is over 500 lines long. Error at 1000?
  • Warning if we are chaining foreach loops or looping over the same variable twice, might be a better way to do things.
  • Warning if we are accessing the property of an object or array without a defensive check, i.e. if ($array[0] != null && count($array[0]) > 1)

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

No branches or pull requests

2 participants