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

Printing static code analysis errors in log #43

Closed
wants to merge 2 commits into from
Closed

Printing static code analysis errors in log #43

wants to merge 2 commits into from

Conversation

tomasbjerre
Copy link

The build log may look like:

[INFO] 
[INFO] --- violations-maven-plugin:1.24:violations (default) @ generic-webhook-trigger ---
[INFO] No references specified, will not report violations in diff
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  55.612 s
[INFO] Finished at: 2019-10-05T10:38:50+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal se.bjurr.violations:violations-maven-plugin:1.24:violations (default) on project generic-webhook-trigger: Too many violations found, max is 0 but found 2
[ERROR] org/jenkinsci/plugins/gwt/GenericTrigger.java
[ERROR] |          |          |          |      |                                   |
[ERROR] | Reporter | Rule     | Severity | Line | Message                           |
[ERROR] |          |          |          |      |                                   |
[ERROR] +----------+----------+----------+------+-----------------------------------+
[ERROR] |          |          |          |      |                                   |
[ERROR] | Spotbugs | RV_RETUR | INFO     | 144  | Return value  of  method  without |
[ERROR] |          | N_VALUE_ |          |      | side effect  is  ignored  <p>This |
[ERROR] |          | IGNORED_ |          |      | code calls a method  and  ignores |
[ERROR] |          | NO_SIDE_ |          |      | the  return  value.  However  our |
[ERROR] |          | EFFECT   |          |      | analysis shows  that  the  method |
[ERROR] |          |          |          |      | (including its implementations in |
[ERROR] |          |          |          |      | subclasses  if  any)   does   not |
[ERROR] |          |          |          |      | produce  any  effect  other  than |
[ERROR] |          |          |          |      | return value. Thus this call  can |
[ERROR] |          |          |          |      | be removed. </p> <p>We are trying |
[ERROR] |          |          |          |      | to reduce the false positives  as |
[ERROR] |          |          |          |      | much as  possible,  but  in  some |
[ERROR] |          |          |          |      | cases  this  warning   might   be |
[ERROR] |          |          |          |      | wrong.   Common    false-positive |
[ERROR] |          |          |          |      | cases   include:</p>   <p>-   The |
[ERROR] |          |          |          |      | method   is   designed   to    be |
[ERROR] |          |          |          |      | overridden  and  produce  a  side |
[ERROR] |          |          |          |      | effect in  other  projects  which |
[ERROR] |          |          |          |      | are  out  of  the  scope  of  the |
[ERROR] |          |          |          |      | analysis.</p> <p>- The method  is |
[ERROR] |          |          |          |      | called  to  trigger   the   class |
[ERROR] |          |          |          |      | loading which  may  have  a  side |
[ERROR] |          |          |          |      | effect.</p> <p>-  The  method  is |
[ERROR] |          |          |          |      | called   just   to    get    some |
[ERROR] |          |          |          |      | exception.</p>  <p>If  you   feel |
[ERROR] |          |          |          |      | that our assumption is incorrect, |
[ERROR] |          |          |          |      | you can use  a  @CheckReturnValue |
[ERROR] |          |          |          |      | annotation to  instruct  FindBugs |
[ERROR] |          |          |          |      | that ignoring the return value of |
[ERROR] |          |          |          |      | this method is acceptable. </p>   |
[ERROR] |          |          |          |      |                                   |
[ERROR] +----------+----------+----------+------+-----------------------------------+
[ERROR] |          |          |          |      |                                   |
[ERROR] | Spotbugs | NP_NULL_ | ERROR    | 140  | Possible null pointer dereference |
[ERROR] |          | ON_SOME_ |          |      | <p>  There   is   a   branch   of |
[ERROR] |          | PATH     |          |      | statement      that,       <em>if |
[ERROR] |          |          |          |      | executed,</em> guarantees that  a |
[ERROR] |          |          |          |      | null value will be  dereferenced, |
[ERROR] |          |          |          |      | which    would     generate     a |
[ERROR] |          |          |          |      | <code>NullPointerException</code> |
[ERROR] |          |          |          |      | when the  code  is  executed.  Of |
[ERROR] |          |          |          |      | course, the problem might be that |
[ERROR] |          |          |          |      | the  branch   or   statement   is |
[ERROR] |          |          |          |      | infeasible  and  that  the   null |
[ERROR] |          |          |          |      | pointer exception can't  ever  be |
[ERROR] |          |          |          |      | executed; deciding that is beyond |
[ERROR] |          |          |          |      | the ability of FindBugs. </p>     |
[ERROR] |          |          |          |      |                                   |
[ERROR] +----------+----------+----------+------+-----------------------------------+
[ERROR] Summary of org/jenkinsci/plugins/gwt/GenericTrigger.java
[ERROR] |          |      |      |       |       |
[ERROR] | Reporter | INFO | WARN | ERROR | Total |
[ERROR] |          |      |      |       |       |
[ERROR] +----------+------+------+-------+-------+
[ERROR] |          |      |      |       |       |
[ERROR] | Spotbugs | 1    | 0    | 1     | 2     |
[ERROR] |          |      |      |       |       |
[ERROR] +----------+------+------+-------+-------+
[ERROR] |          |      |      |       |       |
[ERROR] |          | 1    | 0    | 1     | 2     |
[ERROR] |          |      |      |       |       |
[ERROR] +----------+------+------+-------+-------+
[ERROR] 
[ERROR] 
[ERROR] Summary
[ERROR] |          |      |      |       |       |
[ERROR] | Reporter | INFO | WARN | ERROR | Total |
[ERROR] |          |      |      |       |       |
[ERROR] +----------+------+------+-------+-------+
[ERROR] |          |      |      |       |       |
[ERROR] | Spotbugs | 1    | 0    | 1     | 2     |
[ERROR] |          |      |      |       |       |
[ERROR] +----------+------+------+-------+-------+
[ERROR] |          |      |      |       |       |
[ERROR] |          | 1    | 0    | 1     | 2     |
[ERROR] |          |      |      |       |       |
[ERROR] +----------+------+------+-------+-------+

@tomasbjerre
Copy link
Author

tomasbjerre commented Oct 5, 2019

See also: jenkinsci/plugin-pom#236

And usage: jenkinsci/jenkins#4270

@tomasbjerre tomasbjerre changed the title Printing Spotbugs errors in log before failing build Printing static code analysis errors in log Oct 6, 2019
@oleg-nenashev oleg-nenashev self-requested a review October 11, 2019 17:01
@oleg-nenashev
Copy link
Member

Added to my queue, thanks for the patience

To allow control over column widths.
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