Skip to content

Include erb files for analysis, following Flay #81

New issue

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

By clicking “No 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? No Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2016

Conversation

ABaldwinHunter
Copy link
Contributor

This erb-processing code is lifted directly from flay:
https://github.com/seattlerb/flay/blob/master/lib/flay_erb.rb#L13

@codeclimate/review @noahd1

end
end

class Erubis < ::Erubis::Eruby # :nodoc:
Copy link
Contributor

Choose a reason for hiding this comment

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

💄 The nodoc comment is extraneous since don't use rdoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 thanks

@@ -33,8 +34,47 @@ def overage(issue)
end

def process_file(file)
RubyParser.new.process(File.binread(file), file, TIMEOUT)
if File.extname(file) == ".erb"
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT think about extracting all of this into a Parser class like the other languages have? Keeping that logic here made sense when it was one-liner, but I think this is complex enough that extracting makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually prefer the single file because I think the main class is fairly small (< 5 methods), and adding encapsulating parser files might be adding needless encapsulation.

Let me know if you feel strongly though - and I can make a change.

@ABaldwinHunter
Copy link
Contributor Author

For the CC duplication issue, I considered extracting part of the method, but I think it adds more lines and complexity in this case. More readable as is.

@ABaldwinHunter
Copy link
Contributor Author

ping @wfleming @codeclimate/review Ready for re-review!

end

# taken from Flay, https://github.com/seattlerb/flay/blob/master/lib/flay_erb.rb

Copy link
Contributor

Choose a reason for hiding this comment

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

💄 extra line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@wfleming
Copy link
Contributor

Noticed 2 more small things. If we're going to exclude the duplication issue, maybe we should add it to the ignored fingerprints in config?

Otherwise, LGTM.

@ABaldwinHunter ABaldwinHunter force-pushed the abh-erb-files branch 4 times, most recently from 96a38d8 to de59993 Compare January 28, 2016 15:42
@ABaldwinHunter
Copy link
Contributor Author

@codeclimate/review

Ready for re-review!

@wfleming I

  • removed the begin/rescue clause and output to stderr here, as suggested
  • added codeclimate issue to finger_print excludes

end

def process_erb(file)
erb = File.read(file)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a minor pondering that just occurred to me: we use binread above but just use read here. I suspect this is down to file encodings. You comfortable having these be different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch, binread sounds good to me.

I pulled the code from flay and tested it out locally without an issue, and didn't realize the intention behind using File.binread. Making switch

@wfleming
Copy link
Contributor

One small question, but LGTM.

ABaldwinHunter pushed a commit that referenced this pull request Jan 28, 2016
Include erb files for analysis, following Flay
@ABaldwinHunter ABaldwinHunter merged commit 3ec765e into master Jan 28, 2016
@ABaldwinHunter ABaldwinHunter deleted the abh-erb-files branch January 28, 2016 17:58
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants