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

Universal/DisallowFinalClass: various tweaks #163

Merged
merged 4 commits into from
Dec 1, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 1, 2022

Universal/DisallowFinalClass: minor code tweak

When a class is declared as abstract, it would attempt to record both for the abstract, as well as the not abstract, not final metric.

As a metric can only be recorded once per token, this didn't actually cause any issues, but it still made the code confusing. Fixed now.

Universal/DisallowFinalClass: make tests more descriptive

Universal/DisallowFinalClass: always record the metric

As things were, the sniff would bow out if the opening brace for the class could not be found (yet) and would also not record the final metric in that case, even though for similar code using abstract, the metric would be recorded.

This commit ensures the final metric will now be recorded either way.

Universal/DisallowFinalClass: act on more cases

As things were, the sniff would bow out if the opening brace for the class could not be found (yet).

This commit changes the sniff to act in more cases, i.e. it does require for a (non-empty) token after the class keyword, but once that token is found, the sniff will act.

Includes minor changes to how the message text is build up to prevent weird code snippets being show in the message.

Includes additional test.

When a class is declared as `abstract`, it would attempt to record both for the `abstract`, as well as the `not abstract, not final` metric.

As a metric can only be recorded once per token, this didn't actually cause any issues, but it still made the code confusing. Fixed now.
As things were, the sniff would bow out if the opening brace for the class could not be found (yet) and would also not record the `final` metric in that case, even though for similar code using `abstract`, the metric _would_ be recorded.

This commit ensures the `final` metric will now be recorded either way.
As things were, the sniff would bow out if the opening brace for the class could not be found (yet).

This commit changes the sniff to act in more cases, i.e. it does require for a (non-empty) token after the `class` keyword, but once that token is found, the sniff will act.

Includes minor changes to how the message text is build up to prevent weird code snippets being show in the message.

Includes additional test.
@jrfnl jrfnl added this to the 1.0.0-alpha4 milestone Dec 1, 2022
@jrfnl jrfnl merged commit 9feee1f into develop Dec 1, 2022
@jrfnl jrfnl deleted the universal/disallowfinalclass-various-tweaks branch December 1, 2022 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant