feat: NE0003 — only one namespace declaration per file - #13
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Report when a single file declares more than one namespace, whether sibling or nested (block- and file-scoped). A file that declares multiple namespaces hides types from the name-to-location mapping the other organization rules establish, and complicates NE0001/NE0002. Exactly one namespace per file. - SingleNamespacePerFileAnalyzer flags every namespace declaration except the first, and records whether the reported declaration is nested - Code fix flattens the nested case into a single file-scoped namespace that matches the folder-derived namespace (via the shared FolderNamespace helper), falling back to the concatenated nesting when no anchor is available; the multiple-sibling case is left to NE0001's move-type fix - Honors the file-organization opt-outs and skips generated code - Unit + integration tests, docs/rules/NE0003.md Closes #5
bed9ebc to
e57ed3e
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13 +/- ##
==========================================
- Coverage 99.08% 98.84% -0.25%
==========================================
Files 7 9 +2
Lines 328 432 +104
Branches 62 84 +22
==========================================
+ Hits 325 427 +102
- Partials 3 5 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Raise NE0003 patch coverage over the 95% gate by exercising the analyzer and flatten fix from both the unit and integration flags: - Add an AdhocWorkspace-based runner to the unit suite so the flatten fix runs end-to-end there too (a line hit by only one flag counts as a partial) - Cover the member-rendering branches (leading/interior blank lines, usings, enum and delegate members, trailing-newline style, folder-derived vs concatenated target) - Add the analyzer null-argument guard and the PublishSingleFile / DisableFileOrganizationRules opt-outs to the integration suite
Summary
Implements NE0003: a file should declare exactly one namespace. A file that declares more than one namespace (sibling or nested) hides types from the name↔location mapping the other organization rules establish, and complicates NE0001/NE0002.
Non-compliant
Behavior
PublishSingleFile,NetEvolveAnalyzerDisableFileOrganizationRules) and skips generated code.Code fix
FolderNamespace), falling back to the concatenated nesting (e.g.Outer.Inner) when noRootNamespace/ProjectDiranchor is available.Unit + integration tests and
docs/rules/NE0003.mdincluded.Closes #5