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

Support setting location of rubocop config #66

Closed
jschroeder9000 opened this issue Feb 24, 2015 · 5 comments
Closed

Support setting location of rubocop config #66

jschroeder9000 opened this issue Feb 24, 2015 · 5 comments

Comments

@jschroeder9000
Copy link
Contributor

I am the author of the linter-haml package that provides haml-lint integration with Atom. Unfortunately, I've run into an issue that I don't believe can be solved without support from haml-lint to allow specifying a config location to rubocop.

The nature of the problem is that files are written to a temporary directory before being linted and so rubocop is unable to automatically determine the correct .rubocop.yml file to use and needs to told where it is located. More details can be found at AtomLinter/linter-haml#2.

Is it possible to get haml-lint to support specifying a location for .rubocop.yml?

@sds
Copy link
Owner

sds commented Feb 25, 2015

The way haml-lint does this is by creating a temporary file in the same directory as the original .haml file being linted. This results in rubocop automatically using the correct configuration.

Is there any possibility you could do the same? I would rather not include a hack for a specific linter if it can be avoided.

@jschroeder9000
Copy link
Contributor Author

Thank you for the response.

My package is very simple and I feel a bit like I'm standing with one leg each on the shoulders of two giants (haml-lint and atom's linter), delicately pointing them both in the right direction. :)

The behavior of linter to write files to /tmp is quite deeply ingrained and not configurable. While I can't speak for the intent of the authors, I suspect it may be intentional. Node's tempfile utilities do not have the magic of ruby's TempFile class where the tempfile gets cleaned up with garbage collection pretty much no matter what. By writing to /tmp, no garbage is left behind within the source code in the event of the unexpected, e.g. if the editor crashes.

I'm much more familiar with ruby than node, so this is the natural direction for me to turn first. It seems like the fact that Rubocop::CLI#run accepts overriding ARGV is a boon for HamlLint::CLI to accept a separate option for the location of .rubocop.yml and pass it through in a straight-forward manner.

I know it feels like a bit of a kludge to have two options for config files and this is definitely an edge case, but there are two separate linters at play here. Would you be willing to entertain a pull request that does what I have described?

@sds
Copy link
Owner

sds commented Feb 25, 2015

One last question: is it possible for you to set an environment variable before executing haml-lint?

Rather than expose a flag on the command-line (and having to maintain code that passes that all the way through to the linter), I'd be more comfortable with an environment variable (something like HAML_LINT_RUBOCOP_CONF) that the RuboCop linter can recognize and pass on as a flag to Rubocop::CLI#run.

This would allow the code to only exist in the RuboCop linter, maintaining isolation from the rest of the system.

@jschroeder9000
Copy link
Contributor Author

Setting an environment variable is definitely doable, I have submitted a pull request to linter to support it.

@sds
Copy link
Owner

sds commented Apr 1, 2015

Closing as this seems to have lost steam. Feel free to reopen when this is ready to pursue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants