Skip to content

refactor: declare rule-id as class variable#220

Merged
ktro2828 merged 1 commit into
mainfrom
refactor/sanity/rule-id
Nov 14, 2025
Merged

refactor: declare rule-id as class variable#220
ktro2828 merged 1 commit into
mainfrom
refactor/sanity/rule-id

Conversation

@ktro2828

Copy link
Copy Markdown
Collaborator

What

This pull request refactors the way rule IDs are assigned and registered for format checkers in the t4_devkit.sanity module. Instead of passing the rule ID as an argument to the @CHECKERS.register decorator and the checker class constructor, each checker class now sets its id as a class attribute. The decorator is also simplified to not require the rule ID as an argument. This makes the code more consistent and easier to maintain.

Key changes include:

Refactoring rule ID assignment and registration:

  • Removed the id parameter from the @CHECKERS.register decorator in all checker classes and instead set the id as a class attribute within each checker class, such as FMT001 through FMT018. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]

  • Updated the Checker base class to expect id as a class attribute rather than an instance attribute set in the constructor, and removed the id parameter from the constructor.

Documentation improvements:

  • Updated the docstring for FieldTypeChecker to document the new id class attribute.

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Copilot AI review requested due to automatic review settings November 14, 2025 05:48
@github-actions github-actions Bot added the refactor Refactoring code or increasing performance label Nov 14, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the rule ID registration system by making id a class attribute instead of an instance attribute set via constructor parameter. The @CHECKERS.register() decorator no longer requires the rule ID argument, and instead reads it from the class attribute after registration.

Key Changes:

  • Simplified the @CHECKERS.register() decorator to remove the id parameter
  • Updated all checker classes (FMT001-FMT018, REF001-REF015, REC001-REC006, STR001-STR009, TIV001) to declare id as a class attribute
  • Modified CheckerRegistry._add_module() to read the rule ID from the class attribute

Reviewed Changes

Copilot reviewed 54 out of 54 changed files in this pull request and generated no comments.

Show a summary per file
File Description
t4_devkit/sanity/checker.py Removed constructor that accepted id parameter; declared id as class attribute
t4_devkit/sanity/registry.py Updated register() to not accept id parameter; moved group validation logic into _add_module(); updated build() to instantiate checkers without arguments
t4_devkit/sanity/format/base.py Added id to docstring attributes
t4_devkit/sanity/format/fmt*.py Removed id from decorator call; added id as class attribute
t4_devkit/sanity/record/base.py Added id to docstring attributes
t4_devkit/sanity/record/rec*.py Removed id from decorator call; added id as class attribute
t4_devkit/sanity/reference/base.py Added id to docstring attributes
t4_devkit/sanity/reference/ref*.py Removed id from decorator call; added id as class attribute
t4_devkit/sanity/structure/str*.py Removed id from decorator call; added id as class attribute
t4_devkit/sanity/tier4/tiv001.py Removed id from decorator call; added id as class attribute

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Nov 14, 2025

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ❌

Overall Coverage

Lines Covered Coverage Threshold Status
3900 2125 54% 50% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
t4_devkit/sanity/checker.py 0% 🔴
t4_devkit/sanity/format/base.py 0% 🔴
t4_devkit/sanity/format/fmt001.py 0% 🔴
t4_devkit/sanity/format/fmt002.py 0% 🔴
t4_devkit/sanity/format/fmt003.py 0% 🔴
t4_devkit/sanity/format/fmt004.py 0% 🔴
t4_devkit/sanity/format/fmt005.py 0% 🔴
t4_devkit/sanity/format/fmt006.py 0% 🔴
t4_devkit/sanity/format/fmt007.py 0% 🔴
t4_devkit/sanity/format/fmt008.py 0% 🔴
t4_devkit/sanity/format/fmt009.py 0% 🔴
t4_devkit/sanity/format/fmt010.py 0% 🔴
t4_devkit/sanity/format/fmt011.py 0% 🔴
t4_devkit/sanity/format/fmt012.py 0% 🔴
t4_devkit/sanity/format/fmt013.py 0% 🔴
t4_devkit/sanity/format/fmt014.py 0% 🔴
t4_devkit/sanity/format/fmt015.py 0% 🔴
t4_devkit/sanity/format/fmt016.py 0% 🔴
t4_devkit/sanity/format/fmt017.py 0% 🔴
t4_devkit/sanity/format/fmt018.py 0% 🔴
t4_devkit/sanity/record/base.py 0% 🔴
t4_devkit/sanity/record/rec001.py 0% 🔴
t4_devkit/sanity/record/rec002.py 0% 🔴
t4_devkit/sanity/record/rec003.py 0% 🔴
t4_devkit/sanity/record/rec004.py 0% 🔴
t4_devkit/sanity/record/rec005.py 0% 🔴
t4_devkit/sanity/record/rec006.py 0% 🔴
t4_devkit/sanity/reference/base.py 0% 🔴
t4_devkit/sanity/reference/ref001.py 0% 🔴
t4_devkit/sanity/reference/ref002.py 0% 🔴
t4_devkit/sanity/reference/ref003.py 0% 🔴
t4_devkit/sanity/reference/ref004.py 0% 🔴
t4_devkit/sanity/reference/ref005.py 0% 🔴
t4_devkit/sanity/reference/ref006.py 0% 🔴
t4_devkit/sanity/reference/ref007.py 0% 🔴
t4_devkit/sanity/reference/ref008.py 0% 🔴
t4_devkit/sanity/reference/ref009.py 0% 🔴
t4_devkit/sanity/reference/ref010.py 0% 🔴
t4_devkit/sanity/reference/ref011.py 0% 🔴
t4_devkit/sanity/reference/ref012.py 0% 🔴
t4_devkit/sanity/reference/ref013.py 0% 🔴
t4_devkit/sanity/reference/ref014.py 0% 🔴
t4_devkit/sanity/reference/ref015.py 0% 🔴
t4_devkit/sanity/registry.py 0% 🔴
t4_devkit/sanity/structure/str001.py 0% 🔴
t4_devkit/sanity/structure/str002.py 0% 🔴
t4_devkit/sanity/structure/str003.py 0% 🔴
t4_devkit/sanity/structure/str004.py 0% 🔴
t4_devkit/sanity/structure/str005.py 0% 🔴
t4_devkit/sanity/structure/str006.py 0% 🔴
t4_devkit/sanity/structure/str007.py 0% 🔴
t4_devkit/sanity/structure/str008.py 0% 🔴
t4_devkit/sanity/structure/str009.py 0% 🔴
t4_devkit/sanity/tier4/tiv001.py 0% 🔴
TOTAL 0% 🔴

updated for commit: 6d57910 by action🐍

@ktro2828 ktro2828 merged commit 72683e6 into main Nov 14, 2025
5 checks passed
@ktro2828 ktro2828 deleted the refactor/sanity/rule-id branch November 14, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring code or increasing performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants