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

Fix for #92 Display warning about uninstalled plugins in the Administration section of SonarQube #105

Conversation

bartoszbicz96
Copy link
Contributor

@bartoszbicz96 bartoszbicz96 commented Sep 22, 2020

#92
-creating a new field with warning about uninstalled plugins
-new method checking plugins (getMissingPlugins)

@CLAassistant
Copy link

CLAassistant commented Sep 22, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@lmarniazman lmarniazman left a comment

Choose a reason for hiding this comment

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

Great work, thanks a lot! Just a few comments regarding formatting and functionality needs to be tweaked a little, but looks good otherwise!

static final String ISSUES_SEVERITY_KEY = "sonar.Devon.preview.issuesSeverity";

private static final String QUALINSIGHT = "qualinsight-plugins-sonarqube-smell-plugin";
private static final String PMD = "sonar-pmd-plugin";
Copy link
Member

Choose a reason for hiding this comment

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

Please make sure to use proper devonfw formatting. You can either do it manually by copying the format of code that is already on the master branch, or simply import devonfw format settings into your IDE.

static List<String> FORBIDDEN_REPO_KEYS = new ArrayList<>();
private File pluginDirectory;
private List<String> pluginList;
private List<String> requiredPlugins = Arrays.asList("qualinsight-plugins-sonarqube-smell-plugin",
Copy link
Member

Choose a reason for hiding this comment

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

Putting the required plugins inside a list is fine, but then we wouldn't need them double. As it is now, we have individual strings for all the plugins we need, plus this list. One of them should be enough

.subCategory("").type(PropertyType.TEXT).defaultValue(getMissingPlugins())
.build());
disableRepoKeys();
disableRepoKeys();
Copy link
Member

Choose a reason for hiding this comment

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

Why is this method called twice here?

}
private String getMissingPlugins() {
StringBuilder missingPlugins = new StringBuilder();
missingPlugins.append("Please install plugins listed below: \n\n");
Copy link
Member

Choose a reason for hiding this comment

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

The warning is good like this, but we should only display it if there really is a plugin missing. As it is now, this warning will also be shown when all the plugins are installed. A solution could be to surround the 'context.addExtension()' call inside 'define()' with an if-condition, checking if one of the required plugins is missing.

Copy link
Member

@lmarniazman lmarniazman left a comment

Choose a reason for hiding this comment

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

Looking good, thanks for the PR! Just one small punctuation change and I can approve.

if (missingPlugins.length() != 0) {
missingPlugins.insert(0, "Please install plugins listed below: \n\n");
} else {
missingPlugins.append("All plugins installed properly");
Copy link
Member

Choose a reason for hiding this comment

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

Could you add punctuation after this information?

@lmarniazman lmarniazman added this to the release:2020.12.001 milestone Nov 10, 2020
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

Thanks for this PR. @lmarniazman would you be able to adopt this PR or @bartoszbicz96 are you still available for improving this PR? Otherwise we could merge it as is and you could afterwards create a new PR with the suggested improvements.

@@ -96,15 +57,13 @@ public void define(Context context) {
break;
}
}

if (!(FORBIDDEN_REPO_KEYS.contains(repoKey) || repoKey == null || ruleKey == null)) {
if (!(SonarDevon4jPlugin.FORBIDDEN_REPO_KEYS.contains(repoKey) || repoKey == null || ruleKey == null)) {
Copy link
Member

Choose a reason for hiding this comment

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

I am fine with this PR and its changes but whilst reviewing, I noticed that SonarDevon4jPlugin.FORBIDDEN_REPO_KEYS is odd: Members in Java are either a constant with a NAME_IN_UPPER_CASE_SYNTAX or they are mutable and have a regularCamlCaseName. We should therefore update SonarDevon4jPlugin and change FORBIDDEN_REPO_KEYS to final. Furhter we are making assumtions about initialization order here what is very dangerous and might even change in future SonarQube versions. In order to at least detect such problem, it would IMHO be much more clean to change FORBIDDEN_REPO_KEYS also to private and create a static getter method for it. This method could then even check if the initialization has taken place already (e.g. by another static flag) and otherwise log an error or throw an exception.

@@ -26,5 +58,64 @@ public void define(Context context) {
.type(PropertyType.TEXT)
.defaultValue("{\"architecture\":{\"components\":[\n{\"name\":\"component1\",\\\"dependencies\\\":[]}}\n]}}")
.build());
context.addExtension(PropertyDefinition.builder(DISABLED).name("Warning")
.description("Missing plugins for full initialization of devonfw quality profile").category("devonfw")
.subCategory("").type(PropertyType.TEXT).defaultValue(getMissingPlugins()).build());
Copy link
Member

Choose a reason for hiding this comment

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

if getMissingPlugins() is empty we would still get this warning? This is bad UX. We could simply add an if-statement around this code.

Copy link
Member

Choose a reason for hiding this comment

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

There already is an if-statement in place. If the number of missing plugins is 0, the statement "All plugins installed properly" is displayed. If this was the only critical comment, I suggest we could merge this.

…page_in_the_Administration_section_SonarQube
@lmarniazman
Copy link
Member

Replaced by and continued in PR #115

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.

Display warnings on the 'devonfw' config page in the 'Administration' section of SonarQube
4 participants