Javascript/Typescript exporting const included in executable lines for coverage


I was reading this post about vs SonarQube coverage. It was helpful in understanding why we are getting uncovered lines of code in one of our angular projects.

I have noticed that a lot of lines that are uncovered in SonarQube (and not the are where we export constants. I noticed this is not mentioned in the examples of things that are ignored for coverage in the sonar executable lines.

My questions are:

  1. Is there a reason why export const is considered as executable code in SonarQube?
  2. If not, could it be possible to add this to ignored executable lines?

Additional Info:
We are using the following:

  • SonarQube Enterprise Edition, Version 9.8
  • SonarQubePrepare@5, SonarQubeAnalyze@5 and SonarQubePublish@5 azure pipeline tasks

Hey there.

If you’re providing an for a file, that file itself is saying whether or not that line can be covered by code.

If there’s no information being provided for a file, SonarQube has to “guess” (it runs this code to determine if the line is executable or not).

Is this falling into that second category? This can happen if, for example, there is no coverage being reported on that file at all. It would be very weird if some coverage is being reported on that file by an file, but saying nothing about the export const line.

Hey Colin,

In the those files do not exist, but they are appearing in sonar so I believe it is the second category. For example, some environment files where a replacement is done or some routes files.

We could ignore those files by using sonar.coverage.exclusions but I just found it strange that export const was part of the executable code.


hi @denis_gillespie ,

I tend to agree that export const should not be counted as executable. I want to confirm that we are talking about “purely declarative” export const foo; lines as opposed to when there is an initializer, eg

export const foo = () => { bar(); }

I guess we would still want to see coverage for such lines, right?

hi Tibor , Yes I agree

I created the ticket to improve the analyzer

1 Like