This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new bf953abc305 Add Lombok constructor usage rules (#39743)
bf953abc305 is described below
commit bf953abc3057179cbc8d46274edadd4288318b16
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Sep 6 01:28:29 2026 +0800
Add Lombok constructor usage rules (#39743)
---
.codex/harness/agents/cases.toml | 38 ++++++++++++++++++++++
.../references/rules/java-naming.md | 10 ++++++
2 files changed, 48 insertions(+)
diff --git a/.codex/harness/agents/cases.toml b/.codex/harness/agents/cases.toml
index b8421c275d7..b3e27f1224f 100644
--- a/.codex/harness/agents/cases.toml
+++ b/.codex/harness/agents/cases.toml
@@ -1194,6 +1194,25 @@ policy_binding_profile = "code-write"
policy_assertions = [{source = "java-naming", statements = ["Spell the MySQL
component of a variable identifier `mysql`; `mySQL` is prohibited.", "Spell the
PostgreSQL component of a variable identifier `postgresql`; `postgreSQL` is
prohibited.", "In ordinary variable identifiers, abbreviate `arguments` as
`args`, `parameters` as `params`, `environment` as `env`, `configuration` as
`config`, `configurations` as `configs`, and `properties` as `props`.", "Apply
the abbreviation rule to a w [...]
critical = true
+[[cases]]
+id = "java_lombok_prefers_required_constructor"
+group = "coding / regular"
+description = "Uses RequiredArgsConstructor for required state without
replacing a verified complete-state constructor."
+phase = "coding-standards final check and ordinary completion loop"
+ordinary_loop = true
+profile = "code-write"
+semantic_policy_assertions = true
+prompt = "Continue an authorized in-scope Java implementation whose final
Lombok check found three classes. `Equivalent` has only uninitialized final
fields and uses `@AllArgsConstructor`. `OptionalState` has an uninitialized
final dependency and a default-initialized mutable timeout, uses
`@AllArgsConstructor`, and has no caller, framework, builder, or compatibility
contract requiring the timeout constructor parameter. `CompleteStateFactory`
uses a private `@AllArgsConstructor`, and a v [...]
+decision = "proceed"
+required_actions = ["edit_code", "run_local_checks", "run_pre_handoff_review"]
+allowed_actions = ["inspect_local", "edit_code", "run_local_checks",
"wrap_high_output", "run_pre_handoff_review", "fix_review_findings"]
+forbidden_actions = ["edit_non_code", "edit_unrelated_changes",
"propose_commit_message", "mutate_git", "mutate_remote"]
+required_reasons = ["pre_handoff_review_required"]
+required_summary_terms = ["Equivalent", "OptionalState",
"CompleteStateFactory", "RequiredArgsConstructor", "AllArgsConstructor",
"builder"]
+policy_binding_profile = "code-write"
+policy_assertions = [{source = "java-naming", statements = ["Use
`lombok.RequiredArgsConstructor` instead of `lombok.AllArgsConstructor` when it
generates the required constructor without changing its signature, visibility,
constructor annotations, static factory behavior, or null-check behavior.", "Do
not use `lombok.AllArgsConstructor` when it exposes a field that is not
required to create a valid instance as a constructor parameter.", "Use
`lombok.AllArgsConstructor` only when every p [...]
+critical = true
+
[[cases]]
id = "java_naming_optional_map_parameter_is_exact"
group = "coding / regular"
@@ -1274,6 +1293,25 @@ policy_binding_profile = "coding-standards-audit"
policy_assertions = [{source = "coding-standards", statements = ["Use this
mode only when the user explicitly asks to audit, check, or report
coding-standards compliance.", "Audit the current working tree rather than a
pull request or diff.", "Remain read-only throughout the audit.", "Check every
constrained file and every physical line in scope without sampling."]}, {source
= "standalone-audit", statements = ["An existing-code violation of an
applicable written standard is sufficient to [...]
critical = true
+[[cases]]
+id = "standalone_coding_standards_audits_lombok_constructors"
+group = "policy routing"
+description = "Audits excessive AllArgsConstructor use without rejecting a
verified complete-state constructor."
+phase = "standalone coding-standards audit"
+ordinary_loop = false
+profile = "coding-standards-audit"
+semantic_policy_assertions = true
+prompt = "Perform a standalone coding-standards audit of the exact
current-working-tree file `module-a/src/main/java/example/Constructors.java`.
Its complete supplied content contains `Equivalent`, whose uninitialized final
fields make `@RequiredArgsConstructor` equivalent to its current
`@AllArgsConstructor`, and `CompleteStateFactory`, whose private
`@AllArgsConstructor` is required by a verified builder contract that includes
every generated parameter. Check the complete file, conclud [...]
+decision = "proceed"
+required_actions = ["inspect_local"]
+allowed_actions = ["inspect_local"]
+forbidden_actions = ["edit_code", "edit_non_code", "run_local_checks",
"run_pre_handoff_review", "propose_commit_message", "mutate_git",
"mutate_remote"]
+required_reasons = ["read_only_request"]
+required_summary_terms = ["Non-compliant", "Equivalent",
"CompleteStateFactory", "RequiredArgsConstructor", "builder", "allowed"]
+policy_binding_profile = "coding-standards-audit"
+policy_assertions = [{source = "coding-standards", statements = ["Use this
mode only when the user explicitly asks to audit, check, or report
coding-standards compliance.", "Remain read-only throughout the audit."]},
{source = "standalone-audit", statements = ["An existing-code violation of an
applicable written standard is sufficient to report non-compliance.", "For
every violation, report the rule source, exact requirement, applicability
conditions, exceptions, all violating locations, [...]
+critical = true
+
[[cases]]
id = "java_expressions_resolve_named_constants"
group = "coding / regular"
diff --git a/.codex/skills/coding-standards/references/rules/java-naming.md
b/.codex/skills/coding-standards/references/rules/java-naming.md
index cf933905969..578f5f6835f 100644
--- a/.codex/skills/coding-standards/references/rules/java-naming.md
+++ b/.codex/skills/coding-standards/references/rules/java-naming.md
@@ -37,6 +37,16 @@ Apply these rules to fields, local variables, method and
constructor parameters,
- An abbreviated field name is allowed when neither a Lombok getter nor a
Lombok setter is generated for that field; account for class-level annotations
and field-level `AccessLevel.NONE` overrides before deciding.
- If either a Lombok getter or a Lombok setter is generated for a field, the
full-word field-name rule applies even when generation of the other accessor is
disabled.
+## Lombok-Generated Constructors
+
+- Use `lombok.RequiredArgsConstructor` instead of `lombok.AllArgsConstructor`
when it generates the required constructor without changing its signature,
visibility, constructor annotations, static factory behavior, or null-check
behavior.
+- Do not use `lombok.AllArgsConstructor` when it exposes a field that is not
required to create a valid instance as a constructor parameter.
+- Use `lombok.AllArgsConstructor` only when every parameter it generates
belongs to a verified construction, compatibility, serialization, reflection,
framework, or builder contract that `lombok.RequiredArgsConstructor` cannot
satisfy.
+- Write a manual constructor when neither Lombok constructor annotation
expresses the exact required parameter set or behavior.
+- Before choosing or replacing a Lombok constructor annotation, inspect field
initialization, `final` and `lombok.NonNull` fields, explicit constructors,
`access`, `staticName`, `onConstructor`, builders, constructor callers, and
applicable framework or compatibility contracts.
+- Treat annotation searches as candidate discovery only; report a violation
only after proving equivalent `lombok.RequiredArgsConstructor` behavior or an
unnecessary generated parameter.
+- If the required constructor contract cannot be determined, preserve the
existing annotation in implementation mode and mark the affected check as
blocked in standalone audit mode.
+
## Returned Values
- Return an expression directly when a local variable would have no use other
than its declaration and immediate return.