Giter VIP home page Giter VIP logo

code-quality-configurations's Introduction

Code Quality Styles & Configuration Files

This repository aims for providing coding style guides. In contrast to other guidelines, we try to not set up new, own rules, but instead summarize existing ones that are established in their respective communities. Furthermore, we unite simple layout and code formatting rules with established best practises.

Moreover, we provide configuration files and instructions to automatically check code according to these styles during development and in the build process. The suggested rules and checks should only be a starting point for custom, project-specific ones.

code-quality-configurations's People

Contributors

alexander-krause-glau avatar soerenhenning avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

code-quality-configurations's Issues

Checkstyle configuration cannot be parsed by Gradle plugin

It seems like the Gradle plugin does know about ${config_loc}, which however contradicts the official documentation of the plugin. Further investigation has to be done.

Error message is (using --stacktrace):

Execution failed for task ':checkstyleMain'.
> Unable to create Root Module: config{.../checkstyle.xml}, classpath {...}
...
* Exception is:
...
Caused by: org.xml.sax.SAXException: Property ${config_loc} has not been set

Use provided build.gradle as script plugin

Gradle enables users to use a "inheritance-alike" feature for the build.gradle file of a project. Essentially, this allows developers to provide seperated NAME.gradle files (so-called script plugins) that contain dependencies and tasks for a single topic, e.g., quality assurance.

To apply this feature, one has to use the apply from notation.

In addition with the new (Gradle 4.8) "TextResources can now be fetched from a URI" feature, we should be able to provide a so-called script plugin file for our quality assurance.

I tested this and with a small change to the SpotBugs plugin declaration and an updated version of the Gradle Wrapper (4.8), I was able to include a script plugin file based on our build.gradle.

Unfortunately, Gradle 4.8 is not yet supported by default in the Eclipse Buildship Plugin. We might be able to update the Buildship Plugin ourselves via http://download.eclipse.org/buildship/updates/e48/releases/ and use this overall awesome feature for quality assurance.

P.S. Checkstyle suppression are not possible to be outsourced via URL due to the Checkstyle implementation. Therefore, the checkstyle-suppression.xml is still required per project. This is not bad, since the suppression should be project dependent.

PMD however uses an embedded exclude/include approach in the pmd.xml file. This is a problem, since we cannot allow project dependent excludes. Is there a workaorund, such as using a further file for PMD exclude/includes?

Proposal: Disable undefined reference (UR) rule in PMD

The controversial PMD rule DataflowAnomalyAnalysis contains a check for undefined references.

This check is unnecessary, since Eclipse itself will report the error and the Java compiler will eventually fail. Additionally, it has a high false positive rate. The following example would violate the rule:

for (final String role : rolesAllowed) {
  if (requestContext.getSecurityContext().isUserInRole(role)) {
     return;
    }
}

I propose to disable the UR section of the rule as shown in this SO-post.

Modify Google Checkstyle properties

The Google checkstyle configuration uses allowedAbbreviationLength = 1 for the AbbreviationAsWordInName rule. I have a class CORSResponseFilter that violates this rule, since the abbreviation CORS is too long.

The rule contains a allowedAbbreviations property that can handle exceptions to this rule.

Unfortunately, Checkstyle does not does not support overriding of previously defined rules at the moment (see Checkstyle issue 2873). How should be proceed with this?

I think we should modify the Google checkstyle rules, if all contributors (at the moment only @SoerenHenning) accept the modification.

Therefore I propose to add the allowedAbbreviations property with the default values XML,URL to the Google checkstyle section.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.