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

SONARJAVA-5294 Create rule S7185: @eventlistener methods should have one parameter #4618

Merged
merged 6 commits into from
Jan 28, 2025

Conversation

github-actions[bot]
Copy link
Contributor

You can preview this rule here (updated a few minutes after each push).

Review

A dedicated reviewer checked the rule description successfully for:

  • logical errors and incorrect information
  • information gaps and missing content
  • text style and tone
  • PR summary and labels follow the guidelines

@leonardo-pilastri-sonarsource leonardo-pilastri-sonarsource marked this pull request as ready for review January 27, 2025 14:10
@leonardo-pilastri-sonarsource leonardo-pilastri-sonarsource changed the title Create rule S7185 SONARJAVA-5294 Create rule S7185: @eventlistener methods should have one parameter Jan 27, 2025

Spring provides the `@EventListener` annotation to make a method handle some specific types of events.
This allows to skip the implementation of the `ApplicationListener` interface, making it easier to handle events.
However, the `@EventListener` annotation can only be used on methods that have at most one parameter, which should be the specific event that we want to handle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a line break and remove the however.

Suggested change
However, the `@EventListener` annotation can only be used on methods that have at most one parameter, which should be the specific event that we want to handle.
The `@EventListener` annotation can only be used on methods that have at most one parameter, which should be the specific event that we want to handle.

Spring provides the `@EventListener` annotation to make a method handle some specific types of events.
This allows to skip the implementation of the `ApplicationListener` interface, making it easier to handle events.
However, the `@EventListener` annotation can only be used on methods that have at most one parameter, which should be the specific event that we want to handle.
For multiple types of events, we can use the `classes` argument of the annotation, and provide a list of classes of events that we want to handle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For multiple types of events, we can use the `classes` argument of the annotation, and provide a list of classes of events that we want to handle.
To listen to several types of events, use the `classes` argument of the `@EventListener` annotation.

Copy link

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Copy link

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@leonardo-pilastri-sonarsource leonardo-pilastri-sonarsource merged commit 4c6681e into master Jan 28, 2025
11 of 12 checks passed
@leonardo-pilastri-sonarsource leonardo-pilastri-sonarsource deleted the rule/add-RSPEC-S7185 branch January 28, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants