Skip to content

Commit

Permalink
README: explain how adding new check looks like
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Zamarin <[email protected]>
  • Loading branch information
arthurzam committed Jan 19, 2024
1 parent 831d540 commit f6203f0
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,61 @@ the following::

tox -e py311

Adding new checks
=================

Adding a new check consists of 2 main parts: writing the logic and
documentation, and adding tests for the check.

Writing the logic
-----------------

1. Select the best file for the check under ``src/pkgcheck/checks/``.

2. Create new classes for the results:

- You would need to select the correct result level (style, info, warning,
error) - you might want to consult QA team.

- You would need to select the correct context: category, package, version,
profile, etc.

- Add long user friendly documentation for the result.

- Implement the ``desc`` property which is printed to the user.

3. Create a new class for the check:

- Add long user friendly documentation for the result.

- Put the source of input for the check. This is hard, so best case is to
find similar check and copy the code.

- Define the results it can return.

- Implement the ``feed`` function.

Adding tests
------------

1. Select one of the repos under ``testdata/repos``. In most cases you would
want ``standalone``.

2. Add the ebuild/category/test case you want to catch.

3. ``cd`` into this directory, and run ``pkgcheck scan --cache-dir /tmp -R JsonStream``.
This should yield the results you want to catch (filter out what you expect).

4. Add the results to the test case under:
``testdata/data/repos/${REPO}/${CHECK CLASS}/${RESULT CLASS}/expected.json``

5. If you want to check the fix for the test case, ``git add`` the files under
``testdata/repos/${REPO}``, modify to fix the results, and using
``git diff testdata/repos/${REPO}`` collect the diff.

6. Copy similar patch, add the diff to the patch file, and fix file names, under:
``testdata/data/repos/${REPO}/${CHECK CLASS}/${RESULT CLASS}/fix.patch``


.. _pkgcore: https://github.com/pkgcore/pkgcore
.. _snakeoil: https://github.com/pkgcore/snakeoil
Expand Down

0 comments on commit f6203f0

Please sign in to comment.