racodond / sonar-css-plugin

SonarQube CSS / SCSS / Less Analyzer
GNU Lesser General Public License v3.0
48 stars 27 forks source link

Problem with rule unknown-less-functions #95

Open szegi opened 6 years ago

szegi commented 6 years ago

I started using this plugin and i see that it found an issue with "extend" function

.maine-layout--selected:extend(.maine-layout) {
    color: @text-color-grey;
    .status-new, .status-old, .status-ignore {
        color: @text-color-grey;
    }
}

but it doesnt see problem with

.client-library__some-data {
    &:extend(.client-list__some-data);
}

from what i read, extend is less function from some time http://lesscss.org/features/#extend-feature

racodond commented 6 years ago

Hi,

Which version of the plugin are you running?

David

szegi commented 6 years ago

right now version 4.14

racodond commented 6 years ago

Hi,

I cannot reproduce the issue. Could you please provide the entire file as well a screenshot of the issue?

Thank you

David

agabrys commented 6 years ago

Hello @racodond, I wrote a code which allows to reproduce the error:

unknown-less-functions

The file is compiled successfully.

Environment:

Example file: https://github.com/agabrys/sonarqube-falsepositives/blob/master/src/main/less/d20180410/unknown-less-functions.less

Project: https://github.com/agabrys/sonarqube-falsepositives

Build: mvn clean package sonar

Best Regards

racodond commented 6 years ago

Thanks for the reproducer @agabrys!

It's a tricky bug related to at-rule parsing. The violation here is a side-effect from that parsing issue. keyword: @media prelude:

(max-width: 768px) {
    .navtab-info--dates {
        padding-left: 1%;
    }
}

.customization-form__variation-data, .customization-form__variation-menu {
    display: inline-block;
}

.client-library__some-data {
    &:extend(.client-list__some-data);
}

.variation-layout--selected:extend(.variation-layout) {
    color: #000;
    .status-active, .status-inactive, .status-ignore {
        color: #000;
    }
}

block: none

instead of

keyword: @media prelude: (max-width: 768px) block:

{
    .navtab-info--dates {
        padding-left: 1%;
    }
}

.customization-form__variation-data, .customization-form__variation-menu {
    display: inline-block;
}

.client-library__some-data {
    &:extend(.client-list__some-data);
}

.variation-layout--selected:extend(.variation-layout) {
    color: #000;
    .status-active, .status-inactive, .status-ignore {
        color: #000;
    }
}