refactor: triage the last three SonarQube findings - #102
Merged
Conversation
Rails renders the matching template whether or not the action is defined, so these four were inert. The route and the only: list of every filter that applies already declare that the action exists, and all four paths are covered by request specs — /session/new and /passwords/new confirmed 200 against a running server as well. The convention is recorded in CLAUDE.md so their absence reads as a decision rather than an oversight. Also records why two Sonar findings are refused rather than fixed: the OpenTelemetry requires are lazy by design (ADR 0009 — loading the SDK is what starts it), and rails_helper's is a glob with no static require to hoist. The reasons live in the files, not only on a dashboard. And narrows coverage to what SimpleCov can instrument, so the dashboard stops reading 76.8% for a suite that covers ~99% of the Ruby.
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.
Closes #79, closes #82, and answers #81. These were the
needs-triageSonar issues — each needed a decision rather than a mechanical fix, so this PR is mostly the reasoning.#79 — four empty controller actions: deleted
def edit; end,def new; end× 3. Rails renders the matching template whether or not the action is defined, so all four were genuinely inert.The issue asked for two things to be checked before removing any of them, so:
allow_unauthenticated_access only: %i[new create]andrate_limit … only: :creatematch onaction_name, which comes from the route.posts#edit'sbefore_actionstill run? Yes —only: %i[edit update destroy]matches the action name, not a method.Evidence rather than reasoning alone: all four routes are covered by request specs (
post_ownership_spec,not_found_spec,passwords_spec×2,sessions_spec), 223 request examples pass, and/session/newand/passwords/newboth return 200 against a running server.Deleting rather than adding four "this is empty on purpose" comments: documenting an absence four times is worse than not having the absence. The convention is recorded once in
CLAUDE.mdso the next reader — human or agent — doesn't reintroduce them or read the gap as an oversight.#81 — requires below the top of the file: refused, with the reason in the code
Both are deliberate, and for different reasons, which is why this needed looking at rather than applying:
opentelemetry.rb— loading the SDK is what starts it. Hoisting the requires would mean everyrailscommand pays for instrumentation nobody asked for. That's a behaviour change and it would undo ADR 0009.rails_helper.rb— it's a glob. There is no static require to hoist.Both now carry that reasoning as a comment at the site. A won't-fix whose reason lives only on a dashboard is how a scanner stops being believed — and I can't mark them resolved in SonarCloud from here anyway (that needs the token), so that step is yours: the two findings will keep appearing until they're dismissed there, and the code now tells whoever does it why.
#82 — coverage reading 76.8%: option 1
sonar.coverage.exclusionsforweb/app/javascript/**andweb/app/views/**, with the reasoning insonar-project.properties.Both numbers were honest — they measured different things — but the headline understated the suite, and a metric that has to be explained every time gets dismissed. Coverage now describes the Ruby, because the Ruby is what SimpleCov can instrument.
This narrows one metric, not the scan: every excluded file is still analysed for bugs, smells and vulnerabilities. It's also the prerequisite for making the quality gate blocking, since a gate on a number nobody believes is theatre.
Verified: 380 examples green, RuboCop clean,
script/smoke-testpassed.Generated by Claude Code