GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [on hold] [core] Change method name 'size' to 'getNumViolations', save the old method as deprecated and update documentation by pdhung3012 · Pull Request #1960 · pmd/pmd

Conversation

@pdhung3012

@pdhung3012 pdhung3012 commented Aug 4, 2019 •
edited by adangel
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

This is the updated pull request from the suggestion of author from discussion #1957

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@doubleblinddoubleblinddoubleblind
Change method name 'size' to 'getNumViolations', save the old method …
fb6bb8f
…as deprecated and update documentation
@pdhung3012 pdhung3012 mentioned this pull request Aug 4, 2019
Change method name 'desc' to 'setDescription', 'size' to 'getNumViolations' #1957
Closed
pzygielo
pzygielo reviewed Aug 4, 2019
View reviewed changes
Comment thread pmd-core/src/main/java/net/sourceforge/pmd/Report.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

pzygielo
pzygielo reviewed Aug 4, 2019
View reviewed changes
Comment thread pmd-core/src/main/java/net/sourceforge/pmd/Report.java Outdated
*
* @return number of violations.
*/
public int getNumViolations() {

@pzygielo pzygielo Aug 4, 2019

Copy link
Copy Markdown
Contributor

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.

Why not getNumberOfViolations? Then the whole javadoc could be dropped.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pdhung3012 pdhung3012 Aug 4, 2019

Copy link
Copy Markdown
Author

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.

Hello. I updated the location of @deprecate tag and change the method name to getNumberOfViolations and remove javadoc

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pzygielo pzygielo Aug 4, 2019

Copy link
Copy Markdown
Contributor

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.

I updated the location of @deprecate

But did you read the article I linked to? I mean javadoc @deprecated tag, especially

The @deprecated description in the first sentence should at least tell the user when the API was deprecated and what to use as a replacement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pdhung3012 pdhung3012 Aug 4, 2019

Copy link
Copy Markdown
Author

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.

Oh I see. I updated the java doc of the @deprecated tag

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pzygielo pzygielo Aug 4, 2019

Copy link
Copy Markdown
Contributor

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.

I updated the java doc of the @deprecated tag

Cool. But you still missed:

An @see tag (for Javadoc 1.1) or {@link} tag (for Javadoc 1.2 or later) should be included that points to the replacement method

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@oowekyala oowekyala Aug 4, 2019

Copy link
Copy Markdown
Member

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.

Which - assuming meaning of getNumViolations is well-established (supposedly it's only me, but I will know since now as well - additional points for if the int return type is not explicit enough) is unnecessary. Like for referenced isEmpty method.

I don't really understand this paragraph. What are you saying is unnecessary?

I think eg a comment like the following is simple enough and doesn't repeat content:

/**
 * Returns the number of reported violations. 
 * This is the number of elements yielded by the {@link #iterator()} method. 
 */

The clarification for the confusion is kind of implicit, by just describing what the method returns in plain English, rather than making a separate sentence.

Btw the isEmpty method would IMO also need a javadoc to clarify what it does. It's not just the plain isEmpty you'd find on a List<RuleViolation>, since it also checks the number of errors. Just relying on the name here, you could write

if (!report.isEmpty()) {
 RuleViolation first = report.iterator().next();
}

and get a NoSuchElementException if there are only errors.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pzygielo pzygielo Aug 4, 2019

Copy link
Copy Markdown
Contributor

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.

I don't really understand this paragraph. What are you saying is unnecessary?

Then I meant javadoc. (My fault of writing sentence too complex for myself.)

Your comment for that new method seems very fine.


Btw the isEmpty method would IMO also need a javadoc to clarify what it does.

So is the name correct? But let's not discuss it here and now, as it's not its review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pzygielo pzygielo Aug 4, 2019

Copy link
Copy Markdown
Contributor

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.

I think getNumX is such a well-known convention that there's hardly any ambiguity. Eg in JDK 10, there are 322 179 method declarations with this pattern, versus 55 for getNumberOfX. It's also used more in our own sources (19 vs 6).

So true inconsistency/free-style in JDK alone...
ColorSpace.getNumComponents vs. MouseInfo.getNumberOfButtons. Thanks for pointing to Sun. I'm glad I've never used AWT.
But I won't sleep well. 😞

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pdhung3012 pdhung3012 Aug 4, 2019

Copy link
Copy Markdown
Author

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.

Is there any changes needed from my side on this pull request? Thanks

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@oowekyala oowekyala Aug 4, 2019

Copy link
Copy Markdown
Member

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.

@pdhung3012 Well after reviewing the Report API in #1962, and assuming we follow through on it, this PR won't be needed, as size() would be deprecated with no replacement anyway. Until we decide on it, this PR can be considered on hold.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
doubleblinddoubleblinddoubleblind added 3 commits August 4, 2019 12:38
@doubleblinddoubleblinddoubleblind
change deprecate sign line
cb9db94
@doubleblinddoubleblinddoubleblind
change method name getNumOfViolations to getNumberOfViolation
2e9c531
@doubleblinddoubleblinddoubleblind
remove javadoc
138adb4
@ghost

ghost commented Aug 4, 2019 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
1 Message
📖 This changeset introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
✅ This changeset introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
✅ This changeset introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
✅ This changeset introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report

Generated by 🚫 Danger

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

doubleblinddoubleblinddoubleblind added 3 commits August 4, 2019 12:55
@doubleblinddoubleblinddoubleblind
update javadoc for deprecate method
4c9e4d9
@doubleblinddoubleblinddoubleblind
update java doc
e08c259
@doubleblinddoubleblinddoubleblind
update report javadoc
242ee68
@oowekyala oowekyala mentioned this pull request Aug 4, 2019
[core] Simplify Report API #1962
Closed
@adangel adangel changed the title Change method name 'size' to 'getNumViolations', save the old method as deprecated and update documentation [core] Change method name 'size' to 'getNumViolations', save the old method as deprecated and update documentation Aug 10, 2019
@adangel adangel changed the title [core] Change method name 'size' to 'getNumViolations', save the old method as deprecated and update documentation [on hold] [core] Change method name 'size' to 'getNumViolations', save the old method as deprecated and update documentation Aug 10, 2019
@adangel adangel added this to the 7.0.0 milestone Jun 20, 2020
@oowekyala oowekyala mentioned this pull request Jul 28, 2020
[core] Deprecate report methods #2680
Merged
1 of 4 tasks
@adangel adangel removed this from the 7.0.0 milestone Aug 3, 2020
@adangel

adangel commented Aug 3, 2020

Copy link
Copy Markdown
Member

Replaced by #2680

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel closed this in #2680 Aug 3, 2020
@adangel adangel added the was:wontfix label Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@oowekyala oowekyala oowekyala left review comments
+1 more reviewer
@pzygielo pzygielo pzygielo left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

was:wontfix

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@pdhung3012 @adangel @pzygielo @oowekyala @doubleblinddoubleblinddoubleblind
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.