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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocorrect feature #217

Open
Ana06 opened this Issue Apr 6, 2017 · 8 comments

Comments

Projects
None yet
5 participants
@Ana06
Contributor

Ana06 commented Apr 6, 2017

Supporting autocorrect as Rubocop does would be great. 馃檪

@michaelherold

This comment has been minimized.

Collaborator

michaelherold commented Apr 6, 2017

You're right, this would be a great feature. I consciously steered around that problem and haven't looked into it yet because, frankly, it scares me. 馃槄

@stephen-puiszis

This comment has been minimized.

stephen-puiszis commented Jun 6, 2017

@michaelherold what are the scary issues and how do we start addressing them?

@sds

This comment has been minimized.

Collaborator

sds commented Jun 6, 2017

RuboCop benefits from the hard work of the parser gem, which allows you to modify the syntax tree and re-serialize back to code without much effort.

There is no such parser for HAML. Thus HAML-Lint would effectively need to duplicate the HAML project to support its own parser that allows for mutating the syntax tree.

That is a huge amount of work. I would love to see someone step up to tackle it, but I'm skeptical the benefit is worth the development effort.

@stephen-puiszis

This comment has been minimized.

stephen-puiszis commented Jun 6, 2017

@sds thanks for the info, I assumed it would take quite a bit of work. I did some googling and found the haml_parser gem. My intuition is that it needs a lot of work, but might provide a starting point.

As someone working on a rescue project at the moment, I would love an auto-correct tool to help automate some of the cleanup process as the code is quite awful. I'm sure others would benefit from this as well... but you're right, it all eventually comes down to time and effort

@Ana06

This comment has been minimized.

Contributor

Ana06 commented Jun 7, 2017

@stephen-puiszis is the haml_parser gem really related. In the readme it says:

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem

@Ana06

This comment has been minimized.

Contributor

Ana06 commented Jun 7, 2017

@sds

Thus HAML-Lint would effectively need to duplicate the HAML project to support its own parser that allows for mutating the syntax tree.

Could the parser be useful for something else apart from the autocorrect option? Because then this would have more sense.

and anyway this parser should be an independent gem, not inside haml-lint, right?

@sds

This comment has been minimized.

Collaborator

sds commented Jun 7, 2017

Ideally this would be a contribution to the haml gem itself so that it benefits the most people. However, it's likely that there will be performance tradeoffs in having a parser that collects enough information to support syntax tree editing and code generation, so it would likely be a separate gem.

In either scenario: yes, this should not solely exist in the haml_lint gem.

@sam0x17

This comment has been minimized.

sam0x17 commented Jun 10, 2018

@michaelherold maybe a good initial step would be to add a --fix / --auto-correct option that only fixes rubocop portions of each haml file e.g. the ruby parts. I imagine that would be a lot easier?

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