user1914725
user1914725

Reputation: 27

Enforcing coding standards for new code only

My company's code base is already big. But we are trying to enforce better quality with code hereon.

I am looking for a way to enforce code standards for newly changed code while passing the existing code base.

Currently I have Jenkins as the CI tool, sonarqube as the coordinator into which resharper and stylcop can be plugged in.

but sonarqube is currently producing only a report.

From now on wards, the build has to be failed if it violates a standard or is unstable. Can it be done only at the CI tool level? what are the ways to enforce standards?

Are there alternative or better approaches for my scenario?

Upvotes: 0

Views: 195

Answers (2)

exussum
exussum

Reputation: 18550

You should be able to use

https://github.com/exussum12/coverageChecker

For an offline check. This is written in PHP (so will need PHP on your CI server) but supports many standards for other reports.

This takes the full report, and the diff and only shows the errors on the lines which have changed.

So if you change a non conforming line, you will need to fix the reason it doesn't conform to standards before committing.

All new code has to conform to what ever standard you have set this way

Upvotes: 0

Nils Göde
Nils Göde

Reputation: 545

Your scenario is exactly what Teamscale is built for: Accept the legacy problems and concentrate on the problems in new or modified code. Since Teamscale runs as a server and does an incremental analysis, you don't have to wait for the results or trigger any analysis. It also allows you to configure metric thresholds and quality goals that can be used to decide if a build should break or not. It also has a well-documented REST-API, so it can be easily connected to Jenkins.

Upvotes: 1

Related Questions