RemDelaporteMathurin / h-transport-materials

:bar_chart: Easily access hydrogen transport properties
https://h-transport-materials.readthedocs.io
MIT License
15 stars 12 forks source link

Check for unused variables in codebase #268

Closed RemDelaporteMathurin closed 1 year ago

RemDelaporteMathurin commented 1 year ago

I noticed that if contributors forget to add the properties to the database, tests may pass (because the properties are not tested!).

One way to catch this automatically would be to use vulture.

Running

python -m vulture .\h_transport_materials\property_database\ 

Would provide a report of unused variables and attributes.

We would then integrate that in the CI workflow

jobs:
  pyflakes:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.x  # Choose your desired Python version

      - name: Install vulture
        run: pip install vulture

      - name: Check for unused variables
        run: vulture h_transport_materials\property_database\

      - name: Check vulture output
        run: |
          if [ -n "$(vulture h_transport_materials\property_database\ )" ]; then
            echo "unused variable"
            exit 1
          fi