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

Code quality issues identified by SonarQube #29

Merged

Conversation

davidjsherman
Copy link
Collaborator

Code quality

I have started running SonarQube on the Aseba and Enki code bases, and here is a PR to discuss the improvements to code quality that SonarQube suggests. It includes #28. Each commit in this PR addresses a separate rule; for example, 82303c7 addresses rule cpp:S3230. It should be possible to cherry-pick individual commits. This PR resolves roughly half of the issues identified in the Dashel code.

Remaining issues

The SonarQube report at https://sonarcloud.io/dashboard?id=org.thymio%3Adashel is up to date with this PR, and shows the issues that remain after this PR is applied. The following is a list of the most frequent rules that are still triggered. (Note that each rule page ends with a link to specific issues)

This rule is triggered by the complex class hierarchy in Dashel and the need for protected access to attributes. It might be appropriate to ignore this rule.

This rule can probably be ignored, since the Aseba convention is to specify access separately for attributes and methods:

Finally, two functions are identified as being too complex. At a minimum unit tests (#27) need to be defined before addressing this problem.

@stephanemagnenat
Copy link
Member

I am wondering why "Preprocessor directives should not be indented", if it eases the readability of code?

@stephanemagnenat
Copy link
Member

Also, why "Init-declarator-lists and member-declarator-lists should consist of single init-declarators and member-declarators respectively"?

@@ -1090,47 +1090,6 @@ namespace Dashel
};


/*
Copy link
Member

Choose a reason for hiding this comment

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

I think this block of code should be moved into an example.

@stephanemagnenat
Copy link
Member

Also I would use const reference for exceptions.

@stephanemagnenat
Copy link
Member

Beside these, ok to merge.

@davidjsherman
Copy link
Collaborator Author

We can add exceptions to the rules, especially if there is already a different community standard in the code. That's why I removed the rule that namespaces should start with lower case [a-z], for example. Here is the documentation for the two rules you mentioned:

@stephanemagnenat
Copy link
Member

For the variable declarations separated by a comma, I understand the argument that it might be confusing for some developers who are not used to this feature of C++, so I'm fine with enforcing this rule.

For Preprocessor directives should not be indented, I agree for the change to put the #ifdef without indentation, the rationale makes sense. However, I like the indented includes within the #ifdef, to separate them from the #ifdef itself. What is your personal opinion on that?

Also, I'm more than happy to merge the changes we agree on.

@davidjsherman
Copy link
Collaborator Author

I loathe the preprocessor and I like the rule to not indent #ifdefs because otherwise they give the impression that they respect C++ scoping.

Preprocessor directives with conditional logic make me nervous because I think that most of the time the configuration system is better informed. For example, L77, I should have left the decision to CMake, whether TARGET_OS_IPHONE depended on MACOSX or not.

However, I like the indented includes within the #ifdef, to separate them from the #ifdef itself. What is your personal opinion on that?

If I understand your question, you are referring to the conditional includes L71, L94, etc. In those cases the scoping is the preprocessor itself, and indenting doesn't give a false impression. So if it really improves readability we could manually allow exceptions to the rule in those places.

@davidjsherman
Copy link
Collaborator Author

Rereading my answer, I didn't mean to be passive-aggressive. My opinion is that if you already have a convention then there is no compelling reason to change it.

@davidjsherman
Copy link
Collaborator Author

f30e48c catches exceptions with const references

@stephanemagnenat stephanemagnenat merged commit 8dd8044 into aseba-community:master Jul 17, 2017
@davidjsherman davidjsherman deleted the sonarqube-code-smells branch July 24, 2017 09:19
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