Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

java-review

БесплатноБез исполняемых скриптовНе проверен

Reviewing Java code - what to flag, and what javac, the IDE and SpotBugs already flag for you USE WHEN: you are reviewing, critiquing or auditing existing…

claude-dev-suiteот claude-dev-suite★ 51 звезда на GitHub

Об этом скилле

Reviewing Java

A reviewer's leverage is what the toolchain cannot say. Every check below describes a defect that survives javac -Xlint:all and a default SpotBugs run.

Java's particular trap is that its static analysis is not on by default. javac alone reports very little; SpotBugs, ErrorProne and NullAway are separate build steps that many projects never add. Check the build file before deciding whether a finding is yours.

The snippets are fragments cut down to the defect, not runnable programs.

Already covered - do not spend review on it

Defect Reported by
Unused local variable the IDE; javac only with -Xlint in some cases
Raw type where a generic belongs javac -Xlint:rawtypes
Unchecked cast javac -Xlint:unchecked
Missing @Override the IDE; ErrorProne MissingOverride
equals without hashCode SpotBugs HE_EQUALS_NO_HASHCODE - only if SpotBugs runs
Comparing boxed types with == ErrorProne ReferenceEquality - only if ErrorProne runs
Resource not closed javac -Xlint:try for try-with-resources; SpotBugs OBL_*
String comparison with == SpotBugs ES_COMPARING_STRINGS_WITH_EQ
Switch on enum missing a case javac -Xlint:fallthrough covers fallthrough only, not exhaustiveness

Read pom.xml or build.gradle first. If SpotBugs and ErrorProne are absent — and in a plain Spring Boot starter they are — then rows 5 through 8 are review findings, not tool findings. That is one comment about the build, plus the specific instances.

The table above dates; the tools do not. Verify a default set with mcp__documentation__fetch_docs on technology java-quality — topics spotbugs-bug-descriptions, errorprone-bugpatterns, javac-xlint, nullaway. Those entries point at the indexes the tool authors maintain, so they follow the version the project actually pins rather than the one this skill was written against.

The checks that earn their place

An Optional that reintroduces the null it replaced

Optional<User> u = repo.findById(id);
return u.get().getName();          // throws NoSuchElementException

When you see it: .get() without a preceding isPresent() on the same value, Optional used as a field or a method parameter, or an Optional returned as null.

Ask: what does absence mean here? orElseThrow with a domain exception says it; .get() throws a stack trace that names nothing. An Optional field is worse than a nullable one - it is not Serializable and it costs an allocation to express what a null already expressed.

A stream collected into an immutable list that is later mutated

List<Item> items = stream.collect(Collectors.toList());   // mutable, unspecified
List<Item> items = stream.toList();                       // immutable since 16
items.add(extra);   // UnsupportedOperationException with toList()

When you see it: .toList() (Java 16+) or List.of(...) whose result flows somewhere that adds, sorts or removes.

Ask: does anything downstream mutate this? The two collectors read almost identically and differ exactly here. Collectors.toList() makes no guarantee either way, which is its own reason to be explicit.

A checked exception swallowed to satisfy the compiler

try {
    doWork();
} catch (IOException e) {
    e.printStackTrace();   // execution continues as if nothing failed
}

When you see it: a catch block whose body is printStackTrace(), a bare log, or empty - and no rethrow.

Ask: what does the caller believe happened? The method returns normally, so the failure becomes a wrong result rather than an error. Also: printStackTrace writes to stderr, bypassing the logging pipeline entirely, so it is invisible in production log aggregation.

equals and hashCode that disagree with mutability

record Key(List<String> parts) { }         // hashCode derives from a mutable list
map.put(new Key(parts), value);
parts.add("x");                            // the key is now unfindable

When you see it: a record, or a class with generated equals/hashCode, whose components include a mutable collection or array - then used as a map key or in a set.

Ask: can any component change after insertion? Records give value semantics over whatever they hold, and they hold the reference, not a copy.

An entity's equals based on a generated id

@Entity class Order {
    @Id @GeneratedValue Long id;
    public boolean equals(Object o) { return o instanceof Order x && id.equals(x.id); }
}

When you see it: equals/hashCode on a JPA entity using the surrogate id.

Ask: what is the id before persist? Null - so two unsaved entities in a HashSet collide or throw, and an entity's hash changes when it is flushed, which corrupts any set it is already in. Business keys, or a stable UUID assigned in the constructor, avoid it.

A collect

Полный SKILL.md на GitHub

Установить java-review в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Grep
Glob

FAQ

Что делает скилл java-review?

Reviewing Java code - what to flag, and what javac, the IDE and SpotBugs already flag for you USE WHEN: you are reviewing, critiquing or auditing existing Java code - a "code review", a "review" of a .java file, a diff, a PR or a pull request; deciding what to comment on in Java; avoiding false positives on Java code DO NOT USE FOR: writing, explaining or learning Java - use `languages/java`; anything javac warnings, SpotBugs or a standard Checkstyle run already report (this skill lists those so you can stay silent about them); Spring specifics - use the Spring skills; JPA mapping - use `backend-frameworks/spring-data-jpa`

Как установить скилл java-review?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл java-review запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить java-review с