SonarCSS fails to parse a CSS file, probably due to JSF EL usage

The analysis logs without further information about the actual error

Failed to parse file:///.../foo.css

It is sub-optimal that it does not give any information about what parsing error happened. (Maybe this could improved too)

My guess is, that it is due to JSF EL usage, which is quite common I’d say if JSF is used.
The snippet I guess is causing the error looks like:

.question--content .ui-selectmanycheckbox div.ui-g > div.selected
{
	background-color: #{coreAppearanceBean.getHeaderBackgroundColorAsRgbaWithAlpha('1')};
}

Hi @Vampire

Agree that some information about parsing error would be useful, I’ve created a ticket: https://github.com/SonarSource/sonar-css/issues/158

We use Stylelint under the hood to parse and analyse CSS. About JSF EL, I can’t find any information on how to support this syntax in Stylelint, so I’m afraid we can’t do anything on this side.

Hi @Vampire

I got the same error while doing CSS files analysis. Only few files are got the parse error. Any solution please suggest me.

Thanks

I didn’t find any solution yet.
I now reportet it to Stylelint at https://github.com/stylelint/stylelint/issues/4621, feel free to watch and vote (using thumbs-up reaction, not +1 comments)

@Lena according to the ticket I just created and linked, you need to use a custom parser to support this.

The question is if such custom parser exists

I don’t know.
Maybe ask Google?

Looks like there is no such custom plugin, and even there is one, it’s not so straightforward to integrate it as we rely on stylelint to detect used CSS syntax. Unfortunately as of today CSS analyzer is not our priority so we don’t have bandwidth to take care of JSF EL. Moreover I’m not sure this feature is required for many users.

One workaround for you could be to execute the script which removes EL from your files before analysis (of course without commiting those changes).

Sorry for not being able to provide anything better