Qodana’s public‑access detection depends on naming conventions, raising ambiguity for explicit visibility declarations
0 reputation · 09 Sept 2024, 22:02 UTC
0 reputation · 09 Sept 2024, 22:02 UTC
The goal is to decide whether Qodana should introduce an explicit public‑access declaration to complement its current reliance on naming conventions for marking symbols as public.
At present Qodana treats any identifier without a leading underscore as public, so modules may unintentionally expose internal members, leading to inconsistent security reviews across teams.
Key questions include: Should a dedicated public‑access rule be added to Qodana’s configuration? How would such a rule be expressed (e.g., annotation, flag, or comment)? What impact would this have on existing rule sets and maintenance overhead?
35775 reputation · 10 Sept 2024, 06:51 UTC
Do not add a blanket, Qodana-wide public declaration. If a team needs explicit API visibility, add a narrowly scoped, language-specific inspection that checks an existing visibility mechanism or a supported annotation—not a new rule that changes the meaning of every identifier without a leading underscore.
A dedicated rule is justified for modules with strict internal-boundary policies. It is not justified as default behavior across languages.
Qodana runs language-specific IntelliJ inspections; it does not define one universal access-control model. Java and Kotlin already express public, private, and internal in source code. For those languages, an additional Qodana declaration would usually duplicate existing checks rather than fill a language-level gap.
The premise that every identifier without a leading underscore is public should be treated as a version- and plugin-specific hypothesis, not a general Qodana fact. A convention-based inspection may use that heuristic, but Python-style underscore conventions and JavaScript or TypeScript visibility controls are not equivalent. If such a heuristic currently marks internal members as public, the likely explanation is that the relevant inspection uses naming as a proxy for API status.
| Option | Appropriate use | Main limitation |
|---|---|---|
| Existing language modifier and inspection | Default choice when the language already supports explicit visibility | May not express a team-specific API policy |
| Custom inspection | Enforcing a required declaration in selected modules | Requires parsing, severity, suppression, and baseline design |
| Annotation | Machine-readable declaration supported by the language plugin | May require source changes and plugin-specific support |
| Comment marker | Only when the plugin can parse it reliably | Fragile under formatting, code movement, or generated files |
| Inspection severity toggle | Adjusting an existing diagnostic | Does not create a new declaration mechanism |
Do not invent a generic annotation or configuration key. Exact inspection names, YAML properties, and suppression syntax depend on the installed Qodana release and language plugin.
qodana.yaml for existing visibility or naming inspections.This recommendation assumes Qodana is operating as an inspection runner with a language-specific plugin; current configuration details still require verification. One diagnostic detail would materially change the recommendation: which language plugin is the policy intended for?
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 10 Sept 2024, 07:48 UTC
The current convention, treating identifiers without a leading underscore as public, applies at the module or symbol level, not necessarily across the entire codebase scope. A symbol lacking an underscore is public relative to its containing module's internal visibility expectations.