Skip to content

Commit d339b7a

Browse files
SCANPY-137 Support documented analyzer properties (#163)
1 parent 31600d1 commit d339b7a

File tree

3 files changed

+543
-77
lines changed

3 files changed

+543
-77
lines changed

src/pysonar_scanner/configuration/cli.py

Lines changed: 165 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class CliConfigurationLoader:
2727
@classmethod
2828
def load(cls) -> dict[str, any]:
2929
args = cls.__parse_cli_args()
30-
3130
config = {}
3231
for prop in properties.PROPERTIES:
3332
if prop.cli_getter is not None:
@@ -60,13 +59,24 @@ def __parse_cli_args(cls) -> argparse.Namespace:
6059
type=str,
6160
help="Name of the project in SonarQube",
6261
)
63-
62+
parser.add_argument(
63+
"--sonar-sources",
64+
"-Dsonar.sources",
65+
type=str,
66+
help="The analysis scope for main source code (non-test code) in the project",
67+
)
68+
parser.add_argument(
69+
"--sonar-tests",
70+
"-Dsonar.tests",
71+
type=str,
72+
help="The analysis scope for test source code in the project",
73+
)
6474
parser.add_argument(
6575
"-v",
6676
"--verbose",
6777
"--sonar-verbose",
6878
"-Dsonar.verbose",
69-
action="store_true",
79+
action=argparse.BooleanOptionalAction,
7080
default=None,
7181
help="Increase output verbosity",
7282
)
@@ -114,6 +124,12 @@ def __parse_cli_args(cls) -> argparse.Namespace:
114124
choices=["x64", "aarch64"],
115125
help="Architecture on which the scanner will be running",
116126
)
127+
parser.add_argument(
128+
"--sonar-scanner-metadata-filepath",
129+
"-Dsonar.scanner.metadataFilepath",
130+
type=str,
131+
help="Sets the location where the scanner writes the report-task.txt file containing among other things the ceTaskId",
132+
)
117133

118134
parser.add_argument(
119135
"--skip-jre-provisioning",
@@ -207,6 +223,152 @@ def __parse_cli_args(cls) -> argparse.Namespace:
207223
help="Directory containing the project to be analyzed. Default is the current directory",
208224
)
209225

226+
parser.add_argument(
227+
"--sonar-scm-exclusions-disabled",
228+
type=bool,
229+
action=argparse.BooleanOptionalAction,
230+
help="Defines whether files ignored by the SCM, e.g., files listed in .gitignore, will be excluded from the analysis or not",
231+
)
232+
233+
parser.add_argument(
234+
"-Dsonar.scm.exclusions.disabled",
235+
type=bool,
236+
help="Equivalent to --sonar-scm-exclusions-disabled",
237+
)
238+
239+
parser.add_argument(
240+
"--sonar-filesize-limit",
241+
"-Dsonar.filesize.limit",
242+
type=int,
243+
help="Sets the limit in MB for files to be discarded from the analysis scope if the size is greater than specified",
244+
)
245+
246+
parser.add_argument(
247+
"--sonar-cpd-python-minimum-tokens",
248+
"-Dsonar.cpd.python.minimumTokens",
249+
type=int,
250+
help="Minimum number of tokens to be considered as a duplicated block of code",
251+
)
252+
parser.add_argument(
253+
"--sonar-cpd-python-minimum-lines",
254+
"-Dsonar.cpd.python.minimumLines",
255+
type=int,
256+
help="Minimum number of tokens to be considered as a duplicated block of code",
257+
)
258+
259+
parser.add_argument(
260+
"--sonar-log-level",
261+
"-Dsonar.log.level",
262+
type=str,
263+
choices=["TRACE", "DEBUG", "INFO", "WARN", "ERROR"],
264+
help="Log level during the analysis",
265+
)
266+
parser.add_argument(
267+
"--sonar-qualitygate-wait",
268+
type=bool,
269+
action=argparse.BooleanOptionalAction,
270+
help="Forces the analysis step to poll the server instance and wait for the Quality Gate status",
271+
)
272+
parser.add_argument(
273+
"-Dsonar.qualitygate.wait",
274+
type=bool,
275+
help="Equivalent to --sonar-qualitygate-wait",
276+
)
277+
parser.add_argument(
278+
"--sonar-qualitygate-timeout",
279+
"-Dsonar.qualitygate.timeout",
280+
type=int,
281+
help="The number of seconds that the scanner should wait for a report to be processed",
282+
)
283+
parser.add_argument(
284+
"--sonar-external-issues-report-paths",
285+
"-Dsonar.externalIssuesReportPaths",
286+
type=str,
287+
help="Comma-delimited list of paths to generic issue reports",
288+
)
289+
parser.add_argument(
290+
"--sonar-sarif-report-paths",
291+
"-Dsonar.sarifReportPaths",
292+
type=str,
293+
help="Comma-delimited list of paths to SARIF issue reports",
294+
)
295+
parser.add_argument(
296+
"--sonar-links-ci", "-Dsonar.links.ci", type=str, help="The URL of the continuous integration system used"
297+
)
298+
parser.add_argument(
299+
"--sonar-links-homepage", "-Dsonar.links.homepage", type=str, help="The URL of the build project home page"
300+
)
301+
parser.add_argument(
302+
"--sonar-links-issue", "-Dsonar.links.issue", type=str, help="The URL to the issue tracker being used"
303+
)
304+
parser.add_argument(
305+
"--sonar-links-scm",
306+
"-Dsonar.links.scm",
307+
type=str,
308+
help="The URL of the build project source code repository",
309+
)
310+
parser.add_argument(
311+
"--sonar-branch-name", "-Dsonar.branch.name", type=str, help="Name of the branch being analyzed"
312+
)
313+
parser.add_argument(
314+
"--sonar-pullrequest-key",
315+
"-Dsonar.pullrequest.key",
316+
type=str,
317+
help="Key of the pull request being analyzed",
318+
)
319+
parser.add_argument(
320+
"--sonar-pullrequest-branch",
321+
"-Dsonar.pullrequest.branch",
322+
type=str,
323+
help="Branch of the pull request being analyzed",
324+
)
325+
parser.add_argument(
326+
"--sonar-pullrequest-base",
327+
"-Dsonar.pullrequest.base",
328+
type=str,
329+
help="Base branch of the pull request being analyzed",
330+
)
331+
parser.add_argument(
332+
"--sonar-newcode-reference-branch",
333+
"-Dsonar.newCode.referenceBranch",
334+
type=str,
335+
help="Reference branch for new code definition",
336+
)
337+
parser.add_argument(
338+
"--sonar-scm-revision",
339+
"-Dsonar.scm.revision",
340+
type=str,
341+
help="Overrides the revision, for instance, the Git sha1, displayed in analysis results",
342+
)
343+
parser.add_argument(
344+
"--sonar-build-string",
345+
"-Dsonar.buildString",
346+
type=str,
347+
help="The string passed with this property will be stored with the analysis and available in the results of api/project_analyses/search, thus allowing you to later identify a specific analysis and obtain its key for use with api/new_code_periods/set on the SPECIFIC_ANALYSIS type",
348+
)
349+
parser.add_argument(
350+
"--sonar-source-encoding",
351+
"-Dsonar.sourceEncoding",
352+
type=str,
353+
help="Encoding of the source files. For example, UTF-8, MacRoman, Shift_JIS",
354+
)
355+
parser.add_argument(
356+
"--sonar-working-directory",
357+
"-Dsonar.working.directory",
358+
type=str,
359+
help="Path to the working directory used by the Sonar scanner during a project analysis to store temporary data",
360+
)
361+
parser.add_argument(
362+
"--sonar-scm-force-reload-all",
363+
type=bool,
364+
action=argparse.BooleanOptionalAction,
365+
help="Set this property to true to load blame information for all files, which may significantly increase analysis duration",
366+
)
367+
parser.add_argument(
368+
"-Dsonar.scm.forceReloadAll",
369+
type=bool,
370+
help="Equivalent to --sonar-scm-force-reload-all",
371+
)
210372
parser.add_argument(
211373
"--toml-path",
212374
type=str,

0 commit comments

Comments
 (0)