How would I rewrite this to satisfy the code checker?
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
I'm using Java 1.5, Eclipse Galileo on Mac 10.5.6 and the code checking plug-in (PMD) is complaining about the below code ...
Unfortunately, I'm getting the PMD warning, "Avoid empty while statements". Anyone know how to rewrite the above to satisfy the code checker?
Thanks, - Dave
I'm using Java 1.5, Eclipse Galileo on Mac 10.5.6 and the code checking plug-in (PMD) is complaining about the below code ...
Unfortunately, I'm getting the PMD warning, "Avoid empty while statements". Anyone know how to rewrite the above to satisfy the code checker?
Thanks, - Dave
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Dave:
Change line 3 to read:
John.
Change line 3 to read:
John.
Dave Alvarado
Ranch Hand
Posts: 436
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks but where you put "// your code here ", there's no actual code to put there. If I write it the way you suggest, the code checker still complains about an empty while statement.
- Dave
- Dave
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The semicolon after while ( . . . ) is almost always an error.
Campbell Ritchie
Marshal
Posts: 81616
593
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Why are you using an empty statement after the while in the first place? You appear to be reading something, then not doing anything with it.
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Maybe that's the point, to simply clear all data from the stream. In this case, it most certainly is; the purpose is to calculate the SHA-1 digest.
I think what John meant is put a simple comment in the while loop that immediately explains exactly why you are doing nothing:
This always gets rid of the empty block warnings Eclipse is giving me, and it also tells anyone reading your code why the block is empty.
I think what John meant is put a simple comment in the while loop that immediately explains exactly why you are doing nothing:
This always gets rid of the empty block warnings Eclipse is giving me, and it also tells anyone reading your code why the block is empty.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Marshal
Posts: 81616
593
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thank you, rob. I hadn't realised that.
Dave Alvarado
Ranch Hand
Posts: 436
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
I understood that John meant to only place a comment in the while loop, but what I was saying is when I tried that, PMD, the code checker that is a plug-in for Eclipse, complained with the warning, "Avoid empty while statements", so even with the braces and the comment, it still considers the while statement empty.
So, the question remains, is there any way to rewrite that to achieve the same thing but satisfy the code checker?
Thanks for all your ideas, - Dave
I understood that John meant to only place a comment in the while loop, but what I was saying is when I tried that, PMD, the code checker that is a plug-in for Eclipse, complained with the warning, "Avoid empty while statements", so even with the braces and the comment, it still considers the while statement empty.
So, the question remains, is there any way to rewrite that to achieve the same thing but satisfy the code checker?
Thanks for all your ideas, - Dave
John de Michele
Rancher
Posts: 600
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Dave:
You can put in a NOPMD directive to have PMD ignore that instance:
The //NOPMD directive has to be on the same line as the one you're getting the warning on.
John.
You can put in a NOPMD directive to have PMD ignore that instance:
The //NOPMD directive has to be on the same line as the one you're getting the warning on.
John.
| He baked a muffin that stole my car! And this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |











