Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the indent_size spec option #66

Open
mipo256 opened this issue Dec 19, 2024 · 0 comments
Open

Clarify the indent_size spec option #66

mipo256 opened this issue Dec 19, 2024 · 0 comments

Comments

@mipo256
Copy link
Contributor

mipo256 commented Dec 19, 2024

We need to clarify the indent_size specification option. Maybe we can think about adding new non-normative section as well.

Assume we have these .editorconfig settings:

indent_style = space
indent_size = 2

And we also have the following Java code:

1. package com.something.other;
2. 
3. import java.util.function.Consumer;
4. 
5. public class TestJavaClass {
6. 
7.   public static final String PARAM = "PARAM";
8.
9.  private static final Consumer<Object> MY_CONS = o ->
10.    System.out.println(o);
11.
12.  public static void main(String[] args) {
13.    System.out.println("Hey!");
14.
15.    String property = System
16.      .getProperties()
17.      .getProperty(PARAM);
18.
19.   if (property == null)
20.      return;
21.
22.    System.out.println(property);
23.  }
24.}

The problem is that the spec does not specify the exact indentation rules. For instance, I can implicitly infer the rule, that the intention size of the line must be either the same as the previous (which is, let's say, equal to X), or it should be of the value X + indent_size. That is fine, but there are a couple of problems:

  1. What is the indent size of the line 19 should be? The problem is that we do not have a previous line to look up the indentation according to the rule I described above. We can of course track the indentation of the latest non-empty new line, and then apply the rule above, but this is not mentioned in the spec. It should be somehow clarified.

  2. What is the indentation size of the line 23 should be? On the one hand, this bracket closes the main() method, but it can equally close some if/else statement. The spec does not specify this behavior. But it should

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant