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

Create sections using .editorconfig if present #79

Closed
jayvdb opened this issue Mar 7, 2017 · 8 comments
Closed

Create sections using .editorconfig if present #79

jayvdb opened this issue Mar 7, 2017 · 8 comments

Comments

@jayvdb
Copy link
Member

jayvdb commented Mar 7, 2017

http://editorconfig.org/

@jack17529
Copy link

jack17529 commented Mar 26, 2017

@jayvdb can you please explain the issue in detail like you have done for difficulty/medium issues?

@satwikkansal
Copy link
Member

@jayvdb I've created a custom .editorconfig parser which is able to extract the properties and values. Just wanted to consult you for the next steps :)
Taking a look at the EditorConfig properties wiki, I realized that there is mismatch in the "names of the properties in the EditorConfig files" and the "names of settings of bears that can utilize that property". Example, in ".editorconfig", to define a preferred quotation style, we write quote_type = single but for the QuotesBear, we write preferred_quotation = ' in the ".coafile".

One possible approach is:
We can first define a meta dictionary like

editorconfig_meta = {
	"property_name": [list, of, bears, affected, by, the, property]
}

and because every bear may use this setting differently, we'd have to write mapping logic to map the "property and its value" to the "bear's setting and its value". Example, the values of the property max_line_length in .editorconfig can either be a positive integer or just the string "off". So the mapping logic corresponding to the max_line_length property will have to take care of "off" values because our LineLengthBear doesn't understand what "off" means.

The problem with this approach is we will have to write a lot of mapping functions corresponding to combinations of "every property in .editorconfig and every bear that can utilize that property" and we'll have to maintain them indefinitely. One idea to reduce the mapping maybe to follow the ".editorconfig" like property styles in our bears' settings as well (like replacing preferred_quotation with quote_type in QuoteBear and every other bear with similar setting).

@jayvdb
Copy link
Member Author

jayvdb commented Apr 13, 2017

because every bear may use this setting differently

That may be the case now, but ... we are standardising the names of settings, irrespective of the bears.
i.e. the bears must use the same name for the same concept, and we are fixing discrepancies where they exist.
So, use the most common setting only, and create bugs for any discrepancy that you notice.

@jayvdb
Copy link
Member Author

jayvdb commented Apr 13, 2017

Also, please analyse https://github.com/editorconfig/editorconfig-core-py , to see if it is not usable instead of a custom parser? (and custom writer for coala/coala#4098)

@satwikkansal
Copy link
Member

I did analyze https://github.com/editorconfig/editorconfig-core-py , actually the way it works is not suitable for this issue.
It has only get_properties method as the interface which takes in filename/file globs as argument and returns the configurations of the sections in ".editorconfig" that match the argument passed.
However, I think the behavior we want is to extract the all the sections and corresponding configurations from the ".editorconfig". My implementation of the custom parser is derived from editorconfig-core-py's parser adapted according to our use case.

@jayvdb
Copy link
Member Author

jayvdb commented Apr 13, 2017

I suggest talking with that project, asking them if they are interested in more methods being added, to achieve what you need. (sounds like you have code which could be dropped in easily.) Then everyone benefits; most of all, coala benefits in having someone else maintaining the functionality we rely on.

@Makman2
Copy link
Member

Makman2 commented Jun 14, 2017

Imo this one is not difficulty/low, at least difficulty/medium.

@satwikkansal
Copy link
Member

Done with 5462996

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

No branches or pull requests

5 participants