checkstyle / checkstyle/checkstyle

New Check Or Extension In Identation module needed for Openjdk Line Wrapping

Open
#20,714 2 comments 0 reactions 0 assignees View on GitHub
approved openjdk style
Dominant language
Java
Stars
9.6k
Forks
4.2k
Avg merge
22h 23m
Merged PRs (30d)
232

Description

I have executed the cli and showed it below, as cli describes the problem better than 1,000 words

According to openjdk's updated java-style guidelines on [Wrapping Lines](https://checkstyle.org/styleguides/openjdk-java-style-v6/openjdk-styleguide.html#wrapping-lines):


> Wrapping Lines
A continuation line should be indented in one of the following four ways
Variant 1: With 8 extra spaces relative to the indentation of the previous line.
Variant 2: With 8 extra spaces relative to the starting column of the wrapped expression.
Variant 3: Aligned with previous sibling expression (as long as it is clear that it’s a continuation line)
Variant 4: Aligned with previous method call in a chained expression.

Dos
```
// Variant 1
int anInteger = aMethod(that, takes,
a, lengthy, list, of, arguments);

// Variant 2
int anInteger = that * (is + computed) / using
+ a * complex - expression;

// Variant 3
int anInteger = aMethod(thatTakes,
aLongList,
ofArguments);

// Variant 4
int anInteger = IntStream.of(numbers)
.map(Math::sqrt)
.sum();

```

Don’ts
```
// Mixing of wrapping variants (unless there
// is a logical grouping of arguments)
int anInteger = aMethod(that,
takes,
a, lengthy, list,
of, arguments);

// Don't align with sibling expression if the continuation
// line can be confused with a block indentation
if (somePredicate() ||
someOtherPredicate()) {
System.out.println("Avoid");
}

```

### Is your feature request related to a problem? Please describe.

Checkstyle currently support this rule partially.

### Solution

Either a new check should be implemented for openjdk Identation or some extension needed in `Identation` module. Current` Identation` module can only covers the variant 1 .

Contributor guide

Open the contributing guide

Research direction

Start by running the CLI against the wrapping examples in the issue, then read the Identation module to see how it currently handles continuation indentation. Done means the check supports the OpenJDK wrapping variants described in the issue, including variants beyond the currently supported variant 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.