Skip to content

Conversation

@NanoSector
Copy link
Contributor

Right now it is possible to define a class that has two public methods: exampleOne and exampleTwo. If you do not give this class extra methods and configure the ShouldHaveOnlyOnePublicMethodNamed rule to look for ^example.+$ then it will report success, despite two methods existing with this naming scheme.

This rule will only start failing after introducing a method which does not follow the naming scheme, e.g. foo. This PR aims to fix this by also failing in the exampleOne and exampleTwo scenario.

Note that we interpreted this rule as "can have several public methods, but only one named ...", instead of "should have only one public method and it is named ...", so this might not follow the original intention of the rule.

@NanoSector
Copy link
Contributor Author

@carlosas Your CI setup seems to be completely broken at the moment; is this something you could take a look at?

@carlosas
Copy link
Owner

I'll be able to check it on Monday. Sorry but I'm traveling atm

Right now it is possible to define a class that has two public methods:
`exampleOne` and `exampleTwo`. If you do not give this class extra
methods and configure the ShouldHaveOnlyOnePublicMethodNamed rule to
look for `^example.+$` then it will report success, despite two methods
existing with this naming scheme.

This rule will only start failing after introducing a method which does
*not* follow the naming scheme, e.g. `foo`. This PR aims to fix this by
also failing in the `exampleOne` and `exampleTwo` scenario.

Note that we interpreted this rule as "can have several public methods,
but only one named ...", instead of "should have only one public method
*and* it is named ...", so this might not follow the original intention
of the rule.
@NanoSector NanoSector force-pushed the bugfix/more-than-one-public-method-named branch from 17e4aff to 719f638 Compare June 6, 2025 12:30
@NanoSector
Copy link
Contributor Author

@carlosas I have updated the branch with the latest master, do you happen to have time to look into this PR? :)

@carlosas carlosas merged commit 7e737ea into carlosas:master Jul 10, 2025
14 checks passed
@NanoSector NanoSector deleted the bugfix/more-than-one-public-method-named branch July 21, 2025 06:39
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.

2 participants