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

Add Pre-Commit Hooks for Code Linting and Formatting #219

Open
JaeHyuckSa opened this issue Aug 12, 2024 · 5 comments · May be fixed by #220
Open

Add Pre-Commit Hooks for Code Linting and Formatting #219

JaeHyuckSa opened this issue Aug 12, 2024 · 5 comments · May be fixed by #220
Assignees
Labels
enhancement [PR/Issue] New feature or request

Comments

@JaeHyuckSa
Copy link

Is your feature request related to a problem? Please describe.
I'm always frustrated when inconsistent code styles and formatting issues are committed to the repository. These inconsistencies can make the codebase harder to read and maintain. Additionally, they can lead to avoidable errors that could have been caught by automated linting tools.

Describe the solution you'd like
I propose adding pre-commit hooks to our repository that will automatically run code linting and formatting tools before any commit is made. This will ensure that all code committed adheres to a consistent style and quality standard. Specifically, we can integrate tools like flake8 for Python linting, black for code formatting, isort for sorting imports, and autoflake for removing unused imports and variables.

Describe alternatives you've considered

  1. Manual Code Reviews: Relying on manual code reviews to catch linting and formatting issues, but this is time-consuming and prone to human error.
  2. Post-commit Checks: Implementing post-commit checks, but this means issues are only caught after the code is already in the repository, potentially affecting builds or deployments.

Additional context
Adding pre-commit hooks will streamline our development process and improve overall code quality. It will also save time during code reviews, as reviewers can focus on logic and functionality rather than style issues. Below are some additional resources and examples of how to set up pre-commit hooks with flake8, black, isort, and autoflake:

@JaeHyuckSa JaeHyuckSa added the enhancement [PR/Issue] New feature or request label Aug 12, 2024
@JaeHyuckSa JaeHyuckSa changed the title Adding Pre-Commit Hooks for Code Linting and Formatting Add Pre-Commit Hooks for Code Linting and Formatting Aug 12, 2024
@JaeHyuckSa
Copy link
Author

@dd-jy I'm interested in this part; would it be okay if I submit a PR?

JaeHyuckSa added a commit to JaeHyuckSa/fosslight_dependency_scanner that referenced this issue Aug 12, 2024
@JaeHyuckSa
Copy link
Author

JaeHyuckSa commented Aug 12, 2024

+You might also consider implementing the pre-commit hook using GitHub Actions to create a workflow.

@soimkim soimkim linked a pull request Aug 14, 2024 that will close this issue
5 tasks
@soimkim soimkim assigned JaeHyuckSa and unassigned dd-jy Aug 14, 2024
@soimkim
Copy link
Contributor

soimkim commented Aug 14, 2024

@saJaeHyukc 님, 현재 신규 기능 및 Bug fix, Improvement 가 우선이라 줄 맞춤 관련 이슈는 잠시 보류하고자 합니다. 🙏
이에 생성해주신 PR에 대한 리뷰가 보류될 예정인 점 참고 부탁드립니다.

@soimkim
Copy link
Contributor

soimkim commented Aug 14, 2024

@saJaeHyukc 님, 추가로 PR생성시, pytest -v --flake8를 수행하도록 되어 있습니다.
중복으로 flake8 를 수행하는 것이 아닌지 문의드립니다.

@JaeHyuckSa
Copy link
Author

JaeHyuckSa commented Aug 14, 2024

@saJaeHyukc 님, 추가로 PR생성시, pytest -v --flake8를 수행하도록 되어 있습니다. 중복으로 flake8 를 수행하는 것이 아닌지 문의드립니다.

해당 부분 github actions에 pre-commit으로 통합하여 검사하면 어떨까 싶습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [PR/Issue] New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants