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

Add an ignore list to MixedNames #311

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EduardoVaz06
Copy link
Contributor

This PR adds a setting on MixedNames rule to ignore certain names.

This PR implements a suggestion I have for MixedNames rule. In my company, we have certain patterns in names, so in some cases it's suggested by the rule to comply with the definition, and ends up not being compliant with our pattern. I think it would be good to have a list for names to be ignored.

For example, sometimes the rules suggest to be WParam, and sometimes WPARAM, due to the definition. If we have a pattern to always be WParam, this addition could help to ignore WParam name, and don't raise any issues.

It's up to you to know if this is a desired feature or not.

@Cirras Cirras requested a review from fourls November 7, 2024 02:48
Copy link
Collaborator

@fourls fourls left a comment

Choose a reason for hiding this comment

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

Hi @EduardoVaz06, thanks for making this contribution! I agree with your reasoning and think it's definitely appropriate to include in the core rule behaviour.

Implementation looks great, no problems I can see. I have a couple of suggestions for some extra tests.

.appendImpl("begin")
.appendImpl(" b_IgnoreBool := True;")
.appendImpl("end;"))
.verifyNoIssues();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a test that asserts that the exclusion check is not case-sensitive? e.g. having the excluded name be MyIdentifierName, but the declaration be MYIDENTIFIERNAME and the usage be myidentifiername.


class MixedNamesCheckTest {
private static DelphiCheck createCheck() {
MixedNamesCheck check = new MixedNamesCheck();
check.excludedNames = "b_IgnoreBool";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what this b_ prefix is here - is it a Hungarian notation for boolean variables?

Since identifiers with this prefix is unconventional and would be caught by ClassName, VariableName, etc. it might make people reading this code wonder if there's a specific reason we're testing with this prefix. Could we change this variable name to something else?

@RuleProperty(
key = "excludedNames",
description = "List of names to ignore, separated by a comma.")
public String excludedNames = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a test asserting that you can provide multiple comma-separated names?

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

Successfully merging this pull request may close these issues.

3 participants