Various questions about Code Quality

Hey there,

I’ve been trying to make Gitlab CI’s Code Quality with Code Climate to work and it happened to work… once, after days of struggle. I mean, the only thing I got displayed was a message saying “No changes in code quality” in my merge request panel, I was glad about it as it was finally working. But since that day, I didn’t manage to get anything else than Code Climate artifacts, nothing more in the merge request panel.

Anyway, I was wondering: are reports displayed only in merge request panel? Because I thought that being able to use those reports on each push to a given branch would be more relevant (at least in my case). Code quality is improved and deteriorated by people who add code, why should they wait for the merge request to be created to fix their issues?

Last question: when running Code Climate job, it appears to take about six minutes, which is quite long. Any idea how to improve it?

Thanks for reading!

1 Like

Hey @Laegel, welcome to the forum!

There are a number of prerequisites that need to be fulfilled before the code quality widget will appear in a merge request and sometimes it can be difficult to track down what specifically isn’t allowing it to. Not all of these will apply to your situation, but they’re the ones that I’m aware of currently.

  • You’ve defined a job in your .gitlab-ci.yml which produces the Code Quality report artifact
  • The job must not be the first run. If the Code Quality report doesn’t have anything to compare to, no information will be displayed in the merge request area. That is the case when you add the Code Quality job in your .gitlab-ci.yml for the very first time. Consecutive merge requests will have something to compare to and the Code Quality report will be shown properly.
  • A code error must be present. There has to be a degradation/error in your code as this is what will be displayed in the merge request page. If the code is correct there will be nothing displayed.
  • The .json file must not be too large. There is an existing issue which prevents the code report from displaying when the related .json file is very large.

So, I think you’ve run into a combination of the second and third points here. The reason the job also takes around ~6 minutes to complete is it will need to pull the image for code climate each time manually and because of that, I don’t believe there’s a way to speed it up if you’re using it out of the box.

1 Like

Hey, thanks a lot for your (fast) answer.

Yeah, I did define a job, I’ve even been trying all the various possibilities from this documentation.

The code I was analyzing definitely had code quality issues and was small, assuming it had to work.
It has even been degraded through various merge requests, but still, nothing.

Anyway, I’m not really satisfied with this system. As I said, I’d rather trigger the code quality job to be executed on each push than on merge request creation/update.
I guess I’ll have to look for other solutions, like SonarQube, with a custom CI to be triggered on each commit of desired branches.

One more point: I’ve seen many people creating posts about code quality in GitLab; sometimes because the documentation was not up to date, sometimes because it was just not working. This looks like a complex setup, maybe someone should provide a complete example, a sample project, so people would just reproduce it?

1 Like

Hi @Laegel thanks for your feedback on this feature and the problems you are still experiencing. There is an open issue we are working on for an upcoming release that may address your comments about wanting the code quality values outside the MR. We’d appreciate any feedback in the issue you’d like to share.

Thanks!

This issue is marked closed, I’m experiencing this on the latest GitLab Enterprise Edition [12.8.7-ee]

@bardia - Most often this is due to no code quality artifact being available for the target branch to run the comparison. The Code Quality job will still create a Full Code Quality report after you are running 12.9

Hopefully this helps.

-James

1 Like