intel / cve-bin-tool

The CVE Binary Tool helps you determine if your system includes known vulnerabilities. You can scan binaries for over 200 common, vulnerable components (openssl, libpng, libxml2, expat and others), or if you know the components used, you can get a list of known vulnerabilities associated with an SBOM or a list of components and versions.
https://cve-bin-tool.readthedocs.io/en/latest/
GNU General Public License v3.0
1.24k stars 464 forks source link

docs: add docstrings to parsers/env.py #4539

Closed terriko closed 1 week ago

terriko commented 3 weeks ago

We haven't been entirely consistent about adding python docstrings to every function, and I figured I'd file some easy to fix issues for hacktoberfest participants who are maybe working on getting their commits in this week.

What is a docstring?

Here's a tutorial on docstrings in case you're not sure what they are. Basically I want someone to write a short sentence explaining what a function does and have it put at the top of the function in the way that python expects docstrings to look. (You can also do classes and methods.) Among other things, docstrings can be used by integrated development environments (IDEs) to give contributors a quick overview of the function without having to read the code.

This issue

This issue is for updating the file listed in the title of the issue: parsers/env.py

$ interrogate -vv -i -I -M -C -n -p -f 60.0 parsers/env.py 
================== Coverage for /home/terri/Code/cve-bin-tool/cve_bin_tool/parsers/ ==================
----------------------------------------- Detailed Coverage ------------------------------------------
| Name                                                             |                          Status |
|------------------------------------------------------------------|---------------------------------|
| env.py                                                           |                                 |
|   EnvNamespaceConfig (L17)                                       |                          MISSED |
|   EnvConfig (L26)                                                |                          MISSED |
|   EnvParser (L30)                                                |                         COVERED |
|     EnvParser.parse_file_contents (L42)                          |                          MISSED |
|     EnvParser.run_checker (L64)                                  |                         COVERED |
|------------------------------------------------------------------|---------------------------------|

---------------------------------------------- Summary -----------------------------------------------
| Name               |             Total |             Miss |             Cover |             Cover% |
|--------------------|-------------------|------------------|-------------------|--------------------|
| env.py             |                 5 |                3 |                 2 |                40% |
|--------------------|-------------------|------------------|-------------------|--------------------|
| TOTAL              |                 5 |                3 |                 2 |              40.0% |
--------------------------- RESULT: FAILED (minimum: 60.0%, actual: 40.0%) ---------------------------

You can run that locally to see if you're done, but we also recommend using pre-commit to run pre-checks for you before submitting a pull request. Instructions here:

https://cve-bin-tool.readthedocs.io/en/latest/CONTRIBUTING.html#using-pre-commit-to-run-linters-automatically

Or in short, go to the main cve-bin-tool directory and run the following:

pip install pre-commit
pre-commit install --hook-type pre-commit --hook-type commit-msg

Short tips for new contributors:

Claiming issues:

anchita20 commented 2 weeks ago

I will be working on this issue