Skip to content

Commit

Permalink
Add documentation for the ignored_dependency_scopes setting #1197
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed May 22, 2024
1 parent 62ab093 commit 705ee3f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 10 deletions.
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"

# The style name to use for Pygments highlighting of source code.
pygments_style = "emacs"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
Expand Down
46 changes: 44 additions & 2 deletions docs/project-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ Content of a ``scancode-config.yml`` file:
product_version: '1.0'
ignored_patterns:
- '*.tmp'
- tests/*
- 'tests/*'
ignored_dependency_scopes:
- package_type: npm
scope: devDependencies
- package_type: pypi
scope: tests
See the :ref:`project_configuration_settings` section for the details about each
setting.
Expand All @@ -49,7 +54,6 @@ setting.
You can generate the project configuration file from the
:ref:`user_interface_project_settings` UI.


.. _project_configuration_settings:

Settings
Expand Down Expand Up @@ -86,3 +90,41 @@ within the project.

.. warning::
Be cautious when specifying patterns to avoid unintended exclusions.

ignored_dependency_scopes
^^^^^^^^^^^^^^^^^^^^^^^^^

Specify certain dependency scopes to be ignored for a given package type.
This allows you to exclude dependencies from being created or resolved based on their
scope.

**Guidelines:**

- **Exact Matches Only:** The scope names must be specified exactly as they appear.
Wildcards and partial matches are not supported.
- **Scope Specification:** List each scope name you wish to ignore.

**Examples:**

To exclude all ``devDependencies`` for ``npm`` packages and ``tests`` for ``pypi``
packages, define the following in your ``scancode-config.yml`` configuration file:

.. code-block:: yaml
ignored_dependency_scopes:
- package_type: npm
scope: devDependencies
- package_type: pypi
scope: tests
If you prefer to use the :ref:`user_interface_project_settings` form, list each
ignored scope using the `package_type:scope` syntax, **one per line**, such as:

.. code-block:: text
npm:devDependencies
pypi:tests
.. warning::
Be precise when listing scope names to avoid unintended exclusions.
Ensure the scope names are correct and reflect your project requirements.
2 changes: 1 addition & 1 deletion scanpipe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def get_input_config_file(self):
Priority order:
1. If a config file exists directly in the input/ directory, return it.
2. If exactly one config file exists in a codebase/ immediate subdirectory,
return it.
return it.
3. If multiple config files are found in subdirectories, report an error.
"""
config_filename = settings.SCANCODEIO_CONFIG_FILE
Expand Down
12 changes: 9 additions & 3 deletions scanpipe/tests/data/settings/scancode-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
product_name: My Product Name
product_version: '1.0'
ignored_patterns:
- "*.img"
- "docs/*"
- "*/tests/*"
- '*.tmp'
- 'tests/*'
ignored_dependency_scopes:
- package_type: npm
scope: devDependencies
- package_type: pypi
scope: tests
18 changes: 14 additions & 4 deletions scanpipe/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,26 @@ def test_scanpipe_project_get_env(self):
copy_input(test_config_file, self.project1.input_path)

expected = {
"ignored_patterns": ["*.img", "docs/*", "*/tests/*"],
"product_name": "My Product Name",
"product_version": "1.0",
"ignored_patterns": ["*.tmp", "tests/*"],
"ignored_dependency_scopes": [
{"package_type": "npm", "scope": "devDependencies"},
{"package_type": "pypi", "scope": "tests"},
],
}
self.assertEqual(expected, self.project1.get_env())

config = {"ignored_patterns": None}
self.project1.settings = config
self.project1.save()
expected = {
"ignored_patterns": ["*.img", "docs/*", "*/tests/*"],
}
self.assertEqual(expected, self.project1.get_env())

config = {"ignored_patterns": ["*.txt"], "product_name": "Product1"}
self.project1.settings = config
self.project1.save()
expected["product_name"] = "Product1"
expected["ignored_patterns"] = ["*.txt"]
self.assertEqual(expected, self.project1.get_env())

def test_scanpipe_project_get_env_invalid_yml_content(self):
Expand Down

0 comments on commit 705ee3f

Please sign in to comment.