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

NestingDepth linter not handling rules with no selectors #542

Merged
merged 1 commit into from
Aug 3, 2015

Conversation

cih
Copy link
Contributor

@cih cih commented Aug 1, 2015

Hi Guys,

Noticed #541 so I've taken a look at this, when I wrote the initial implementation I didn't realise that node.parsed_rules could potentially return nil. If my understanding is correct a RuleNode can in some cases return nil when it contains no CSS selectors so I've gone for a somewhat quick and dirty null object, maybe an implicit return statement would do the job?

Hope this helps!

@@ -30,8 +32,7 @@ def visit_rule(node)

def ignore_selectors?(node)
return unless config['ignore_parent_selectors']

simple_selectors(node.parsed_rules).all? do |selector|
simple_selectors(node.parsed_rules || null_selector).all? do |selector|
Copy link
Owner

Choose a reason for hiding this comment

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

Unless we intend to use the `null_selector elsewhere, it seems simpler (and less code) to have an early return.

return unless node.parsed_rules

@sds
Copy link
Owner

sds commented Aug 3, 2015

Thanks for the fix, @cih!

I agree an early return would be preferred in this case. Otherwise this looks good!

@cih
Copy link
Contributor Author

cih commented Aug 3, 2015

No worries, cheers for the feedback @sds, updated.

@sds sds merged commit c6ff3ae into sds:master Aug 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants