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

[ci][test] Modifications to static analysis contribution via Tomasbjerre #5116

Merged

Conversation

jimschubert
Copy link
Member

This extends on submission by @tomasbjerre in #5040 by moving the PMD and Spotbugs plugin execution to a separate profile static-analysis. This keeps CheckStyle in the default build because it added a very minimal amount of time to execution.

Once merged, I'd like to extend the Sonar CI GitHub Action to be a static analysis action which caches the xml reports generated by these plugins as build artifacts. This will give us SonarCloud as a means for evaluating the static analysis, and allow for contributors to download the *.xml reports from the action. Once the GitHub action is updated, we can also close #33 as well.

Core contributors may run static analysis with:

mvn -Pstatic-analysis install

The analysis is separated from default functionality to reduce impact to community contributions. SpotBugs/PMD may add a non-trivial amount of time to builds on some machines.

cc @OpenAPITools/generator-core-team

Closes #5040

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

tomasbjerre and others added 3 commits January 25, 2020 17:42
 * Also using project.parent.basedir and avoiding relative paths in pom files.
 * Filtering out samples.
This moves the static-analysis checks to a standalone profile. Core
contributors may run static analysis with:

```
mvn -Pstatic-analysis install
```

The analysis is separated from default functionality to reduce impact to
community contributions. SpotBugs/PMD may add a non-trivial amount of
time to builds on some machines.
@jimschubert jimschubert added this to the 4.2.3 milestone Jan 26, 2020
@auto-labeler
Copy link

auto-labeler bot commented Jan 26, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.


<!-- For source/class naming, see https://spotbugs.readthedocs.io/en/stable/filter.html#java-element-name-matching -->
<Match>
<!-- Ignore all source files with samples in path name -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could argue that the generated code should also be free from issues found by static code analysis. I'm not sure about excluding samples here.

I can see how users have different code standards and running Checkstyle and PMD is not worth the effort, but I'm not sure it is good to exclude Spotbugs here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another reason to exclude these here is that I assume most users use custom templates. Analyzing our "samples" is therefore very much like analyzing our tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another concern is that only a very small subset of our samples are Java :
Maybe we could later work out the pattern to exclude everything but java client and server outputs in the samples directory.

<configuration>
<failOnError>false</failOnError>
<!-- https://spotbugs.readthedocs.io/en/stable/effort.html -->
<effort>min</effort>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that it does not run by default, perhaps it does not need to be min?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can evaluate this once it's hooked into the target pipeline.

@tomasbjerre
Copy link
Contributor

The travis.yml can be extended to include this tool:
https://www.npmjs.com/package/violation-comments-to-github-command-line

But perhaps you would rather have Sonar do the commenting.

@jimschubert
Copy link
Member Author

The travis.yml can be extended to include this tool:
npmjs.com/package/violation-comments-to-github-command-line

But perhaps you would rather have Sonar do the commenting.

We have some cleanup to do with respect to how much is being logged in Travis. As it is, both Travis and CirciCI UIs lock up my browser because of the amount of text output. I'm looking at modifying our logger to reduce duplicated log lines, and once that's done I will look out the outputs in other CI.

I'm thinking the static-analysis profile may also be run in CircleCI for contributor outputs.

@jimschubert jimschubert merged commit c0f7b47 into OpenAPITools:master Jan 26, 2020
@jimschubert jimschubert deleted the tomasbjerre-static-analysis branch January 26, 2020 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discuss static analysis options
2 participants