Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(java): stop a bare @Immutable fabricating a generated class (#2361)
Raghav Chamadiyafac4534f53d0
diff --git a/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/jvm_codegen.py b/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/jvm_codegen.pyindex c1d98de3e..5bbe52eb2 100644--- a/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/jvm_codegen.py+++ b/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/jvm_codegen.py@@ -87,8 +87,11 @@ def jvm_codegen_synthetic_symbols(start_line=line, end_line=line,file_info=file_info, parent_name=None,))- if (_has_marker_annotation(node, "Immutable", src)- or _has_marker_annotation(node, "Value.Immutable", src)):+ # Qualified marker only: a bare ``@Immutable`` is the unrelated+ # thread-safety annotation, which generates nothing. Ceiling: a file+ # that statically imports ``Value.Immutable`` and then writes a bare+ # ``@Immutable`` is missed, which needs the import table to tell apart.+ if _has_marker_annotation(node, "Value.Immutable", src):out.append(build_synthetic_symbol(name=f"Immutable{type_name}", kind="class",signature=f"public class Immutable{type_name} extends {type_name}",diff --git a/tests/unit/ingestion/test_jvm_synthesis.py b/tests/unit/ingestion/test_jvm_synthesis.pyindex 5d8aef73e..0540893aa 100644--- a/tests/unit/ingestion/test_jvm_synthesis.py+++ b/tests/unit/ingestion/test_jvm_synthesis.py@@ -116,6 +116,29 @@ class TestJvmCodegen:)assert "ImmutablePerson" in names, names+ def test_bare_immutable_is_not_immutables(self, tmp_path: Path) -> None:+ """``javax.annotation.concurrent.@Immutable`` generates nothing."""+ names = _names(+ tmp_path, "CacheStats.java", "java",+ "import javax.annotation.concurrent.Immutable;\n"+ "@Immutable public final class CacheStats {}\n",+ )+ assert "ImmutableCacheStats" not in names, names++ def test_qualified_immutable_still_emits(self, tmp_path: Path) -> None:+ names = _names(+ tmp_path, "Order.java", "java",+ "import org.immutables.value.Value;\n"+ "import org.mapstruct.Mapper;\n"+ "import com.google.auto.value.AutoValue;\n"+ "@Value.Immutable public abstract class Order {}\n"+ "@Mapper interface OrderMapper { String map(String s); }\n"+ "@AutoValue abstract class OrderBox {}\n",+ )+ assert "ImmutableOrder" in names, names+ assert "OrderMapperImpl" in names, names+ assert "AutoValue_OrderBox" in names, names+def test_no_annotation_no_synthesis(self, tmp_path: Path) -> None:names = _names(tmp_path, "Plain.java", "java",