Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max-file-line-count rule #842

Merged
merged 4 commits into from
Oct 27, 2016

Conversation

DanPurdy
Copy link
Member

@DanPurdy DanPurdy commented Aug 25, 2016

Adds the rule max-file-line-count to enforce the length of a file

If a file exceeds the default / user specified line count the following message will be provided:
This file has 301 lines, which exceeds the maximum of 300 lines allowed.

closes #841

<DCO 1.1 Signed-off-by: Dan Purdy dan@danpurdy.co.uk>

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 97.268% when pulling 8bc0aa7 on DanPurdy:feature/max-file-line-count into 54c25a9 on sasstools:develop.

@DanPurdy DanPurdy modified the milestone: 1.10 Sep 1, 2016
@@ -0,0 +1,27 @@
# Max File Line Count

Rule `max-file-line-count` will enforce that a files length doesn't exceed a certain number of lines
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo - file's

length: 300
},
'detect': function (ast, parser) {
var result = [];
Copy link
Member

@bgriffith bgriffith Oct 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified as all we need is the end.line of the stylesheet node (ast), which will always be ast.end.line

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...  
  'detect': function (ast, parser) {
    var result = [];

    if (ast.end.line > parser.options.length) {
      result = helpers.addUnique(result, {
        'ruleId': parser.rule.name,
        'line': ast.end.line,
        'column': 0,
        'message': 'This file has ' + ast.end.line + ' lines, which exceeds the maximum of ' + parser.options.length + ' lines allowed.',
        'severity': parser.severity
      });
    }

    return result;
  }
...

@DanPurdy DanPurdy closed this Oct 27, 2016
@DanPurdy DanPurdy reopened this Oct 27, 2016
@coveralls
Copy link

coveralls commented Oct 27, 2016

Coverage Status

Coverage increased (+0.007%) to 97.57% when pulling 8167ede on DanPurdy:feature/max-file-line-count into 1a1f695 on sasstools:develop.

@coveralls
Copy link

coveralls commented Oct 27, 2016

Coverage Status

Coverage increased (+0.007%) to 97.579% when pulling bb321ce on DanPurdy:feature/max-file-line-count into d2c4ce4 on sasstools:develop.

@bgriffith bgriffith merged commit 21a20eb into sasstools:develop Oct 27, 2016
@DanPurdy DanPurdy deleted the feature/max-file-line-count branch October 28, 2016 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule suggestion: Max file line count
3 participants