-
-
Notifications
You must be signed in to change notification settings - Fork 797
UndocumentedPublicProperty and UndocumentedPublicFunction should include objects #3940
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
UndocumentedPublicProperty and UndocumentedPublicFunction should include objects #3940
Conversation
The class returned was null for functions inside an object, resulting in a false negative, so we instead use containingClassOrObject to determine if the containing object is public or not.
…etermining eligibility for UndocumentedPublicProperty check containingClass() returns null when checking an object not nested in another class, making it ineligible to check. Switching to containingClassOrObject allows properties in an obect to be checked.
Thanks for the fix 🙏 That's really appreciated. |
Codecov Report
@@ Coverage Diff @@
## main #3940 +/- ##
=========================================
Coverage 83.44% 83.44%
Complexity 3149 3149
=========================================
Files 456 456
Lines 9014 9014
Branches 1754 1754
=========================================
Hits 7522 7522
Misses 565 565
Partials 927 927
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the rule also flag interfaces with this implementation?
@schalkms yes, interfaces were being flagged before with |
Summary
Given an
object
with an undocumented public function or property, I would expect theUndocumentedPublicFunction
rule orUndocumentedPublicProperty
rule to fail the build. However, the behavior of the rules is inconsistent in regards toobjects
.The following code is failed when the rules are enabled and an object is nested in a class, as expected:
However, if the object is promoted to a top level object, then the rules will not fail the function or property.
Changes
I discovered that the
containingClass()
function used in both rules to determine if the function or property is part of a public class returns null if the function or property is in anobject
. We can change this behavior to check if theobject
is public or not by replacing the usage ofcontainingClass()
withcontainingClassOrObject
. In this way, we can treat an undocumented function or property in anobject
the same as one in a regularclass
.I changed both
UndocumentedPublicFunction
andUndocumentedPublicProperty
to utilizecontainingClassOrObject
instead ofcontainingClass()
. I also added test cases for public and privateobject
cases as well as a nestedobject
test case. For the test cases I added to theUndocumentedPublicPropertySpec
, I renamed two of the existing test cases with ambiguous names to avoid confusion with the test cases I added.