Skip to content

Conversation

@zon-tiobe
Copy link
Contributor

@zon-tiobe zon-tiobe commented Jan 21, 2026

Conform the description in the ticket itself (RM-37342):

One should check whether another module is defined as well. Closing a module early is not a problem per se, e.g. if you have top level code.

Also added a few more examples of what is considered to be OK:

  • one case where there is code outside a single module, which covers this exact case.
  • one case containing code next to two submodules, which should also be OK since the code is inside a module.

As it is easier to cover multiple cases in individual files, the tests have switched from a single file-and-expected construct to a directory containing multiple files.

@brouwers-tiobe brouwers-tiobe self-requested a review January 22, 2026 09:03
Copy link
Contributor

@brouwers-tiobe brouwers-tiobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention of this ticket is not fully clear to me. My interpretation would be: code outside of a module is OK, but having additional modules within a file is not. Meaning the rule should only trigger on module declarations, and nothing else.

But the current implementation also explicitly checks for code outside of modules, implying 'it is not OK to have code outside of modules if there is more than one module in the file'.

This seems incorrect to me, because in either case it is not applicable:

  1. If there is only one module, code outside it is allowed (as per this ticket)
  2. If there is more than one module, the problem is the additional modules. Once the additional modules are moved out of the file, the other code outside the module is not problematic (as in point 1)

Perhaps it would be best to verify the requirement here.

@zon-tiobe
Copy link
Contributor Author

On hold while awaiting a reply on the requirements.

@zon-tiobe
Copy link
Contributor Author

Discussed the requirements. The 'code outside module' check can be removed as discussed in #110 (review). As such, it has been removed and the tests have been updated to reflect that.

Decided to leave the test code as it is.

@zon-tiobe zon-tiobe changed the title RM-37342: Code outside a module is OK if there is no more than 1 module in a file RM-37342: Remove check on code outside modules Jan 23, 2026
@zon-tiobe
Copy link
Contributor Author

Also adapted the pull request to reflect the new changes.

Copy link
Contributor

@brouwers-tiobe brouwers-tiobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@zon-tiobe zon-tiobe merged commit 172bc10 into main Jan 23, 2026
3 checks passed
@zon-tiobe zon-tiobe deleted the 37342-single-module-file-rework branch January 23, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants