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

FEATURE: Add cops for plugins #41

Merged
merged 1 commit into from Feb 28, 2024
Merged

FEATURE: Add cops for plugins #41

merged 1 commit into from Feb 28, 2024

Conversation

Flink
Copy link
Contributor

@Flink Flink commented Jan 31, 2024

This patch adds some new rules to have saner defaults for our plugins. These rules should help in particular with disabled plugins.

The new cops are:

  • Discourse/Plugins/CallRequiresPlugin: checks requires_plugin is called in controllers.
  • Discourse/Plugins/DiscourseEvent: checks on is called instead of DiscourseEvent.on.
  • Discourse/Plugins/NamespaceConstants: checks constants are not defined outside the plugin namespace.
  • Discourse/Plugins/NamespaceMethods: checks methods are not defined outside the plugin namespace.
  • Discourse/Plugins/NoMonkeyPatching: checks existing classes are not patched in plugin.rb using class_eval.
  • Discourse/Plugins/UseRequireRelative: checks load is not used to load dependencies.

@Flink Flink self-assigned this Jan 31, 2024
@Flink Flink changed the title WIP: FEATURE: Add rules for plugins FEATURE: Add cops for plugins Feb 26, 2024
@Flink Flink marked this pull request as ready for review February 26, 2024 15:46
This patch adds some new rules to have saner defaults for our plugins.
These rules should help in particular with disabled plugins.

The new cops are:

* Discourse/Plugins/CallRequiresPlugin: checks `requires_plugin` is
  called in controllers.
* Discourse/Plugins/DiscourseEvent: checks `on` is called instead of
  `DiscourseEvent.on`.
* Discourse/Plugins/NamespaceConstants: checks constants are not defined
  outside the plugin namespace.
* Discourse/Plugins/NamespaceMethods: checks methods are not defined
  outside the plugin namespace.
* Discourse/Plugins/NoMonkeyPatching: checks existing classes are not
  patched in `plugin.rb` using `class_eval`.
* Discourse/Plugins/UseRequireRelative: checks `load` is not used to
  load dependencies.
@Flink Flink merged commit f1a646e into main Feb 28, 2024
2 checks passed
@Flink Flink deleted the loic-plugins-rules branch February 28, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants