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

Implement AxivionSuite tool which queries the Axivion Dashboard for violations #20

Merged
merged 13 commits into from
Mar 29, 2019

Conversation

arturbosch
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Mar 23, 2019

Codecov Report

Merging #20 into master will decrease coverage by 1.42%.
The diff coverage is 55.67%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #20      +/-   ##
===========================================
- Coverage     80.83%   79.4%   -1.43%     
- Complexity     1371    1393      +22     
===========================================
  Files           225     231       +6     
  Lines          4685    4967     +282     
  Branches        375     394      +19     
===========================================
+ Hits           3787    3944     +157     
- Misses          744     864     +120     
- Partials        154     159       +5
Impacted Files Coverage Δ Complexity Δ
...lysis/warnings/axivion/RemoteAxivionDashboard.java 0% <0%> (ø) 0 <0> (?)
.../plugins/analysis/warnings/axivion/AxRawIssue.java 100% <100%> (ø) 6 <6> (?)
...plugins/analysis/warnings/axivion/AxIssueKind.java 100% <100%> (ø) 4 <4> (?)
...lugins/analysis/warnings/axivion/AxivionSuite.java 3.48% <3.48%> (ø) 0 <0> (?)
...lysis/warnings/axivion/DefaultTransformations.java 89.31% <89.31%> (ø) 8 <8> (?)
...ugins/analysis/warnings/axivion/AxivionParser.java 92.85% <92.85%> (ø) 4 <4> (?)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 371599f...f7d1d21. Read the comment docs.

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class AxivionParser extends IssueParser implements Serializable {
Copy link
Member

Choose a reason for hiding this comment

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

Why do you implement IssueParser?

private String credentialsId = StringUtils.EMPTY;
private String basedir = "$";

public AxivionSuite(final String projectUrl, final String credentialsId, final String basedir) {
Copy link
Member

Choose a reason for hiding this comment

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

package private and @VisibleForTesting


public AxivionSuite(final String projectUrl, final String credentialsId, final String basedir) {
super();
// empty constructor required for stapler
Copy link
Member

Choose a reason for hiding this comment

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

remove comment

return new AxivionParser(projectUrl,
withValidateCredentials(),
expandBaseDir(run, this.basedir)
).parse(null);
Copy link
Member

Choose a reason for hiding this comment

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

null not required if parser does not implement interface.

import org.apache.commons.lang3.StringUtils;
import org.apache.http.auth.UsernamePasswordCredentials;

import com.cloudbees.plugins.credentials.CredentialsMatchers;
Copy link
Member

Choose a reason for hiding this comment

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

Where is this dependency coming from? Jenkins-core?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It comes from the Credentials Plugin which is shipped by Jenkins and can't be deinstalled.

public class AxivionSuite extends Tool {

private static final long serialVersionUID = 8670135727302169818L;
static final String ID = "AxivionStoppingSoftwareErosion";
Copy link
Member

Choose a reason for hiding this comment

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

quite a long URL, is this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it was intented, but AxivionSuite is ok too. Changed it.

Copy link
Member

Choose a reason for hiding this comment

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

It is used as URL to the results, so typically it does contain only lowercase characters (separated by -), see https://github.com/jenkinsci/warnings-ng-plugin/blob/master/SUPPORTED-FORMATS.md.

assertTrue(ArrayUtils.contains(expected, actual.getType()));
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Some more tests would be helpful.

};
for (final Issue actual : report) {
assertTrue(ArrayUtils.contains(expected, actual.getType()));
}
Copy link
Member

Choose a reason for hiding this comment

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

check all properties of an issue

final String payload = new String(new Resource(svJson).asByteArray());

Report report = new Report();
parser.processIssues(
Copy link
Member

Choose a reason for hiding this comment

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

why don't you test the parse() method?

@arturbosch
Copy link
Contributor Author

Thanks for the review, I incorporated your comments.

What is the right way to integrate jelly templating?
When this plugin was a standalone plugin jelly worked, I had a hard time migrating the jelly files to the new resources package structure. Lastly it worked, now after renaming the ID field, my custom three input fields again disappeared.
The parser still works for already configured projects.

I can't reproduce the architecture violations locally.
On CI it tells me not to use Jenkins.getInstance(). What is the prefered way to retrieve the credentials ids from jenkins?

Is assertAll not allowed in your code base due to longer CI runs?

@uhafner
Copy link
Member

uhafner commented Mar 25, 2019

What is the right way to integrate jelly templating?
When this plugin was a standalone plugin jelly worked, I had a hard time migrating the jelly files to the new resources package structure. Lastly it worked, now after renaming the ID field, my custom three input fields again disappeared.
The parser still works for already configured projects.

See https://github.com/jenkinsci/warnings-ng-plugin/pull/20/files#r268879821

I can't reproduce the architecture violations locally.
On CI it tells me not to use Jenkins.getInstance(). What is the prefered way to retrieve the credentials ids from jenkins?

The architecture violations are from a simple unit test, why does it not work locally?

I'm currently preparing the project to be used in my testing course here at the university, so I want that everybody conforms to my guidelines. I hope they are not too academic;-) Two new rules that are now enforced with an architecture test:

I generally want to forbid direct Jenkins.getInstance from code since these code parts cannot be unit tested (you need an integration test). In order to make auch a code testable you need to call the Jenkins façade that handles these calls. The Jenkins façade can be replaced in a unit test with a stub. If your method to Jenkins instance is not available yet, please add it to the façade. Here is an example: https://github.com/jenkinsci/warnings-ng-plugin/blob/master/src/test/java/io/jenkins/plugins/analysis/core/util/ModelValidationTest.java

Is assertAll not allowed in your code base due to longer CI runs?

No, I simply want to use only one assertion framework in my modules and that is AssertJ. Otherwise contributors get confused if some use JUnit4, some use JUnit5, some AssertJ, etc.

@arturbosch
Copy link
Contributor Author

arturbosch commented Mar 26, 2019

Thanks for the input, resources/AxivionSuite/config.jelly and ID=axivion-suite made it work.

Just the "document all public members" I would call too academic as I remember this requirement from my studies in Bremen ;).
All other checks are impressive, need to look into the architecture checks for detekt too :).

@uhafner
Copy link
Member

uhafner commented Mar 28, 2019

@uhafner uhafner merged commit c755bc0 into jenkinsci:master Mar 29, 2019
@uhafner
Copy link
Member

uhafner commented Mar 29, 2019

Thanks!

@arturbosch arturbosch deleted the support-axivion-parser branch April 1, 2019 05:50
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