Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/pysonar_scanner/configuration/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,16 @@ def __create_parser(cls):
scanner_behavior_group.add_argument(
"--sonar-cpd-py-minimum-tokens",
"-Dsonar.cpd.py.minimumTokens",
"--sonar-cpd-python-minimum-tokens",
"-Dsonar.cpd.python.minimumTokens",
type=int,
help="Minimum number of tokens to be considered as a duplicated block of code",
)
scanner_behavior_group.add_argument(
"--sonar-cpd-py-minimum-lines",
"-Dsonar.cpd.py.minimumLines",
"--sonar-cpd-python-minimum-lines",
"-Dsonar.cpd.python.minimumLines",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -Dsonar.cpd.python.minimumLines we shouldn't need, since any non-consumed parameter beginning with -D... will be passed along.

Same applies for minimum tokens.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep them as we will pass the property to the correct sonar.cpd.py....

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I think the PR can be merged then

type=int,
help="Minimum number of tokens to be considered as a duplicated block of code",
)
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/test_configuration_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,29 @@ def test_both_boolean_args_given(self):
configuration = CliConfigurationLoader.load()
self.assertTrue(configuration.get(SONAR_SCM_EXCLUSIONS_DISABLED))

@patch(
"sys.argv",
[
"myscript.py",
"--token",
"myToken",
"--sonar-project-key",
"myProjectKey",
"-Dsonar.cpd.python.minimumLines=10",
"--sonar-cpd-python-minimum-tokens",
"20",
],
)
def test_cpd_config_with_py_property_name(self):
configuration = CliConfigurationLoader.load()
expected_configuration = {
SONAR_TOKEN: "myToken",
SONAR_PROJECT_KEY: "myProjectKey",
SONAR_CPD_PYTHON_MINIMUM_LINES: 10,
SONAR_CPD_PYTHON_MINIMUM_TOKENS: 20,
}
self.assertDictEqual(configuration, expected_configuration)

@patch(
"sys.argv",
[
Expand Down