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

Automated linting and style check #93

Open
mkaze opened this issue Jun 2, 2021 · 5 comments
Open

Automated linting and style check #93

mkaze opened this issue Jun 2, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mkaze
Copy link
Contributor

mkaze commented Jun 2, 2021

I was wondering if there is a plan to have automated style check and linting for contributions. This would be really useful to keep the codebase clean and consistent. Additionally, some pre-commit hooks for running style checks and linting could be set up to address this locally before pushing commits.

@therealansh
Copy link
Contributor

I agree with you @mkaze it would really lead to a clean codebase. May i suggest adding this linters to github actions if in future we go with set up a CI. This would actually automate and contributor need not to worry about formatting the code before pushing.

@mkaze
Copy link
Contributor Author

mkaze commented Jun 2, 2021

May i suggest adding this linters to github actions if in future we go with set up a CI.

Yeah, I also meant it to be automated, i.e. use it as an step of CI in Github PRs. I only mentioned the pre-commit hooks as an (optional and) additional tool for the contributors so that they can check and fix the related errors before pushing their commits.

@zaleslaw
Copy link
Collaborator

zaleslaw commented Jun 2, 2021

Hi, @therealansh and @mkaze do you have any ideas what style-check/linting should be added? Share best practices here in the thread

@zaleslaw zaleslaw added help wanted Extra attention is needed enhancement New feature or request labels Jun 2, 2021
@mkaze
Copy link
Contributor Author

mkaze commented Jun 3, 2021

@zaleslaw Well, I am relatively new to Kotlin in particular, but what I have in mind is a set of simple and standard checks as part of CI process (hopefully, triggered automatically on PR) which is a common practice in various projects written in different languages. These checks may include all the tests a standard linter or style-checker tool would do, e.g. checking unused imports/variables/functions, small optimizations/improvements, formatting issues according to a fixed style convention, redundant whitespaces/linebreaks, etc. Note that I am not necessarily have the more complex checks in my mind (things like function complexity checks or code smell); actually, I am more inclined towards standard style-checking and basic linting instead of a full-suit of static code analysis.

For example, I have used black in Python projects; it's very opinionated and cannot be customized very much, however it makes the codebase to follow a fixed set of rules for formatting which in turn keeps it more readable and consistent. A quick search led me to ktlint (from Pinterest), ktfmt (from Facebook) and detekt for Kotlin. Surely, you have a better idea which one might be a good choice (from the description it seems to me that ktlint is a good option, especially because it's opinionated and therefore we don't need to spend time on configuring it or defining rules). Anyways, whatever we choose at the end, we can simply set it up in Github Actions to be run on each PR to make sure the formatting is correct and consistent (here is an example).

@zaleslaw
Copy link
Collaborator

zaleslaw commented Jun 3, 2021

My colleagues advised me ktlint and detekt (both together), so I'll try to set up them for the project in the nearest future.

@zaleslaw zaleslaw self-assigned this Jun 15, 2021
@zaleslaw zaleslaw added this to the 0.3 milestone Sep 13, 2021
@zaleslaw zaleslaw modified the milestones: 0.3, 0.4 Sep 20, 2021
@zaleslaw zaleslaw modified the milestones: 0.4, 0.5 Feb 16, 2022
@ermolenkodev ermolenkodev removed this from the 0.5 milestone Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants