Address several SonarQube issues reported on the main branch. - #2419
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request addresses SonarQube findings on the main branch by applying small, targeted refactors and shell/Docker/YAML hygiene fixes across tests, Python code, Dockerfiles, scripts, and GitHub workflows.
Changes:
- Simplifies/refactors a few Python constructs to satisfy static analysis (safe handler iteration, reduced redundant list conversions, clearer intermediate variables, improved typing).
- Hardens shell/Docker usage with safer quoting and stderr for error paths.
- Scopes GitHub Actions
permissionsat the job level and adds a maintenance changelog fragment.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit_tests/application/test_control.py | Iterates over a stable copy of logger handlers when cleaning up, avoiding mutation-during-iteration warnings. |
| src/simtools/simtel/simtel_config_reader.py | Refactors list extension logic to compute repetition count once (SonarQube-style readability). |
| src/simtools/simtel/nsb_trigger_calculator.py | Removes an unreachable/irrelevant triggers is None check since triggers is always set to an int. |
| src/simtools/db/mongo_db.py | Makes db_client explicitly nullable via a union type annotation. |
| src/simtools/configuration/configurator.py | Removes an unnecessary list() wrapping while building argparse token lists. |
| docs/changes/2419.maintenance.md | Adds a maintenance changelog fragment for this SonarQube cleanup. |
| docker/Dockerfile-simtools-dev | Consolidates RUN steps to reduce layers and keep git safe.directory setup in the same RUN chain. |
| docker/Dockerfile-corsika7 | Improves quoting for variable expansions and refactors long shell/awk lines for safer parsing. |
| database_scripts/setup_local_db.sh | Sends error messages to stderr and uses [[ ... ]] tests under bash. |
| database_scripts/purge_local_db.sh | Sends error messages to stderr, uses [[ ... ]], and makes helper functions explicitly return success. |
| .github/workflows/CI-unittests.yml | Moves permissions: contents: read from workflow-level to per-job permissions. |
| .github/workflows/CI-docs.yml | Moves permissions: contents: read from workflow-level to the docs job. |
| .github/workflows/build-sim_telarray.yml | Moves permissions: contents: read from workflow-level to the dependency-config job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Not entirely sure where these issues come from - maybe from a SonarQube update? I haven't seen them before - anyway, this branch fixes them.