zarfld / LinuxCnc_PokeysLibComp

Pokeys comp for LinuxCnc using https://bitbucket.org/mbosnak/pokeyslib.git
MIT License
5 stars 0 forks source link

Improve Code Quality and Consistency #62

Open zarfld opened 1 day ago

zarfld commented 1 day ago

Improve Code Quality and Consistency

Description:

To ensure that the codebase remains maintainable, scalable, and easy to contribute to, we need to implement various code quality checks and tools across the repository. These improvements will focus on enforcing consistent coding standards, improving code readability, and reducing the chances of introducing bugs.

Tasks:

  1. Set up Linting for Python (pokeys_py):

    • Integrate flake8 as the linter for Python code.
    • Add a configuration file (.flake8) to define coding standards (PEP8 or project-specific rules).
    • Ensure that the linting process runs on every pull request via GitHub Actions CI.
  2. Set up Static Code Analysis for C/C++ (pokeys_rt and other C components):

    • Integrate cppcheck or a similar static code analysis tool for C/C++ code.
    • Add a configuration file for cppcheck to define rules for code analysis.
    • Ensure that the static analysis runs on every pull request via GitHub Actions CI.
  3. Enforce Consistent Code Formatting:

    • Add a code formatter like black for Python code to automatically enforce consistent formatting.
    • Add a code formatting tool like clang-format for C/C++ code.
    • Create a pre-commit hook that formats code automatically before commit or runs the formatter via CI.
  4. Add Type Annotations (Python):

    • Add type annotations to Python functions and methods in the pokeys_py module.
    • Use mypy to check for type consistency across the codebase.
    • Configure mypy to run during CI checks.
  5. Add Unit Tests Coverage:

    • Increase unit test coverage in the repository.
    • Use tools like pytest-cov to track code coverage.
    • Integrate a code coverage report in the CI pipeline (use services like Codecov or Coveralls).
  6. Configure GitHub Actions:

    • Ensure the CI pipeline runs all quality checks (linting, static analysis, formatting, type checking) and unit tests on every pull request and commit.
    • Fail the pipeline if any code quality check does not pass.

Acceptance Criteria:

References: