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

Plain Reporter prints Error Message for result even if there are no errors #14

Open
ojintoad opened this issue Jan 7, 2013 · 3 comments

Comments

@ojintoad
Copy link

ojintoad commented Jan 7, 2013

for(JsHintResult result : report.getResults()) {
   output.append("\n");
   output.append(getFileFailureMessage((result.getFile()) + "\n"));
   for(JsHintError error : result.getErrors()) {
        output.append(getIssueMessage(error.getReason(), error.getEvidence(), error.getLine(), error.getCharacter()) + "\n");
   }
}

The above code block is from https://github.com/philmander/ant-jshint/blob/master/src/main/java/com/philmander/jshint/report/PlainJsHintReporter.java

When the reporter runs, it just checks once if the entire report has errors and then assumes all results are errors. It would be nice to have logic that distinguishes results with errors from results with successes. I.e. : if(results.getNumErrors() > 0) { error logic } else { success logic }

This might be nice for some of the xml reporters as well but they don't write language that indicates an error but rather just print out all result files by name with no error report. The PlainJsHintReporter uses the getFileFailureMessage every time, no matter if the individual file failed or not, which is confusing.

Thank you very much for this library, it is by far the easiest way to get JSHint integrated into a build system on multiple platforms (windows and linux). I'm using it through Gradle and it works wonderfully.

@philmander
Copy link
Owner

Hi, I'm glad to hear you find the task useful!

Specifically, what 'non-error' result data would you expect to see?

Currently a JSHintResult object is just a wrapper for a Javascript file name and any JSHint errors found. And I think the only data I can get out of JSHint after it has evaluated a JS file are the errors, if any.

Phil

@philmander
Copy link
Owner

Oh, I'm thinking you'd just like to see an exact list of the files which were actually validated right?

@ojintoad
Copy link
Author

ojintoad commented Jan 8, 2013

Right, I'd like to either see no data or a success message.

Just to make sure I'm not communicating poorly:

I have 10 js files. 5 of them have errors. I run jshint on all 10. The plain reporter prints the getFileFailure message ("JSHint validation failed for " + file;) for all the files (10 times), which isn't correct for 5 of the files. Instead it should either print out only the message for the 5 files that fail or print out 5 success messages and 5 failure messages.

for(JsHintResult result : report.getResults()) {
   if(result.getNumErrors() > 0) { //print error results
      output.append("\n");
      output.append(getFileFailureMessage((result.getFile()) + "\n"));
      for(JsHintError error : result.getErrors()) {
        output.append(getIssueMessage(error.getReason(), error.getEvidence(), error.getLine(), error.getCharacter()) + "\n");
      }
   } else {
      //optionally print a success message for this result
   }
}

ojintoad added a commit to ojintoad/ant-jshint that referenced this issue Jan 29, 2013
philmander#14 was reported by me.
I specified the code change in a comment and then decided to try to fix
it.
@ojintoad ojintoad mentioned this issue Jan 29, 2013
ojintoad added a commit to ojintoad/ant-jshint that referenced this issue Sep 3, 2013
philmander#14 was reported by me.
I specified the code change in a comment and then decided to try to fix
it.
ojintoad added a commit to ojintoad/ant-jshint that referenced this issue Sep 6, 2013
philmander#14 was reported by me.
I specified the code change in a comment and then decided to try to fix
it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants