zmoazeni / csscss

A CSS redundancy analyzer that analyzes redundancy.

Home Page:http://zmoazeni.github.io/csscss/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parser picks up end of comment as part of next selector

ericpromislow opened this issue · comments

Given this CSS:

@import url("f1/reset.css");
@import url("f1/base.css");

/*
div.x {
    padding: 3px;
}
*/

div.app-edit {
    /*border: 2px solid #ddd;*/
    padding: 2px 0px;
    margin: 2px 0px;
    background: url(../img/app-edit.png) no-repeat right top;
}

div.app-ide {
    /*border: 2px solid #ddd;*/
    padding: 2px 0px;
    margin: 2px 0px;
    background: url(../img/app-ide.png) no-repeat right top;
}

div.app-ide-edit {
    /*border: 2px solid #ddd;*/
    padding: 2px 0px;
    margin: 2px 0px;
    background: url(../img/app-ide-edit.png) no-repeat right top;
}

csscss 1.2.0 -v gives this output:

{*/

div.app-edit}, {div.app-ide} AND {div.app-ide-edit} share 4 rules
  - background-position: right top
  - background-repeat: no-repeat
  - margin: 2px 0px
  - padding: 2px 0px

I thought this was strange because I know I spent a lot of time on the comments. It looks like it's actually due to the @import rules. I really gotta fix that, or ignore them #41

If the file is:

/*
div.x {
    padding: 3px;
}
*/

div.app-edit {
    /*border: 2px solid #ddd;*/
    padding: 2px 0px;
    margin: 2px 0px;
    background: url(../img/app-edit.png) no-repeat right top;
}

div.app-ide {
    /*border: 2px solid #ddd;*/
    padding: 2px 0px;
    margin: 2px 0px;
    background: url(../img/app-ide.png) no-repeat right top;
}

div.app-ide-edit {
    /*border: 2px solid #ddd;*/
    padding: 2px 0px;
    margin: 2px 0px;
    background: url(../img/app-ide-edit.png) no-repeat right top;
}

It will output normally.

I appreciate the bug report. I'm going to close this as a dup of #41 too. And make a comment to look at this specific edge case.