Skip to content

Add editorconfig to help OSS contributors #2898

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

Merged

Conversation

brandonpayton
Copy link
Contributor

When switching between many different open source code bases, it can be cumbersome to constantly change editor settings in order to respect a given project's basic style preferences. EditorConfig is a popular format for representing those preferences so editors can automatically respect them.

Many editors support EditorConfig out of the box, and many others have EditorConfig plugins:
https://editorconfig.org/#pre-installed

This commit adds an EditorConfig to the ModSecurity project. It is most likely not perfect because the chosen indentation varies a bit throughout the project, but hopefully it provides a good basis for most ModSecurity editing.

When switching between many different open source code bases, it can be
cumbersome to constantly change editor settings in order to respect a
given project's basic style preferences. EditorConfig is a popular
format for representing those preferences so editors can automatically
respect them.

Many editors support EditorConfig out of the box, and many others have
EditorConfig plugins:
https://editorconfig.org/#pre-installed

This commit adds an EditorConfig to the ModSecurity project. It is most
likely not perfect because the chosen indentation varies a bit
throughout the project, but hopefully it provides a good basis for most
ModSecurity editing.
@airween airween added the 3.x Related to ModSecurity version 3.x label Feb 27, 2024
@airween airween self-assigned this Feb 27, 2024
@airween
Copy link
Member

airween commented Feb 27, 2024

Hi @brandonpayton,

thanks for sharing this idea.

Generally I'm not against of this, but as you wrote:

It is most likely not perfect because the chosen indentation varies a bit throughout the project

so I don't know how useful is this.

If we want to maintain the indentation through the whole code, we should choose a tool and implement it - eg. astyle.

Perhaps this is a good topic for discussion.

@theseion
Copy link
Collaborator

theseion commented Feb 28, 2024

IMO, formatters and editorconfig are complementary. Depending on your IDE, you may be able to run the formatter often, e.g., on save, but it's different that using editorconfig because it formats the code after you've already written it. editorconfig changes how you write code in the first place. You can still fix up things with a formatter after the fact but if both are close in their configuration, I think that helps. It's certainly less disruptive than seeing the code you just wrote being rearranged all the time.

My 2 cents: add an editorconfig. It doesn't hurt.

@marcstern
Copy link

editorconfig looks a very good start. And a formatter like astyle could be added as well later.
With good policies, the code could be easier to read (and so to maintain).
And it could definitely help with PR.

@airween
Copy link
Member

airween commented Feb 29, 2024

Thanks @theseion and @marcstern, I'm going to merge this soon.

@marcstern: do you think could we add this to v2/master too?

Copy link
Member

@airween airween left a comment

Choose a reason for hiding this comment

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

LGTM

@airween airween merged commit 625f9a5 into owasp-modsecurity:v3/master Mar 5, 2024
@brandonpayton brandonpayton deleted the add-editorconfig branch March 12, 2024 23:13
@brandonpayton
Copy link
Contributor Author

Thank you, @airween!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Related to ModSecurity version 3.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants