Lines of code in single file as Quality Gate Metric


(Nenashev Anatoliy) #1

Is it possible to set a limit for lines of code in any file as Quality Gate metric?
I mean:
for example we want to set limit to 1k lines. user added or changed any file in project, and now file has 1,2k lines of code. quality gate has to fail in this case


(Colin Mueller) #2

Nenashev,

Most languages have a rule for “Files should not have too many lines of code”. This will raise an issue on files that exceed your threshold (the deafult, in fact, is 1000 lines).

If you are using a quality gate (like the default Sonar Way) that doesn’t allow any issues to be introduced on new code, it should fail when new code pushes a file past the 1000 line limit (or when a new file with 1000+ lines is introduced).

Colin