Skip to content

Conversation

@cbuescher
Copy link
Member

This change adds the OneStatementPerLineCheck to our checkstyle precommit
checks. This rule restricts the number of statements per line to one. The
resoning behind this is that it is very difficult to read multiple statements on
one line. People seem to mostly use more than one statement per line in short
lambdas and switch statements in our code base, but just going through the
necessary changes this rule enforces already uncovered some actual problems
in randomization in test code, so I think its worth it.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@cbuescher
Copy link
Member Author

For context: I opened this as a follow up to #33676 after I (or better my Eclipse IDE) stumbled into some offending double semicolons in import statements. Those would be complained about as well with this additional checkstyle rule.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also opened a separate PR to separate this change: #33678

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it wasn't reformatting, just my Auto-Save trailing whitespace removal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also opened a separate PR for this change: #33681

@cbuescher cbuescher force-pushed the one-statement-per-line branch from 2cdcb73 to d3dd075 Compare September 14, 2018 14:08
@elasticdog
Copy link
Contributor

This job triggered CI during a migration of the master. Kicking off an additional build for you manually...

Jenkins, test this please.

This change adds the OneStatementPerLineCheck to our checkstyle precommit
checks. This rule restricts the number of statements per line to one. The
resoning behind this is that it is very difficult to read multiple statements on
one line. People seem to mostly use it in short lambdas and switch statements in
our code base, but just going through the changes already uncovered some actual
problems in randomization in test code, so I think its worth it.
@cbuescher cbuescher force-pushed the one-statement-per-line branch from d3dd075 to e74219d Compare September 17, 2018 11:09
Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of like the switch statements the old way but if we can't convince checkstyle that that is ok then I think this is a net win.

import static org.elasticsearch.index.mapper.TypeParsers.parseTextField;

/** A {@link FieldMapper} for full-text fields with annotation markup e.g.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you extract the formatting changes to this file into another commit so I don't have to review them? I'd be happy with you just pushing it so long as all it does is remove trailing spaces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I didn't realize this did a reformatting. Will clean this up.

@cbuescher
Copy link
Member Author

I kind of like the switch statements

I can understand that for short lines, but I must say I think readability still suffers. Plus this rule fund the two leftovers in test I mentioned, I think its worth it.

@cbuescher cbuescher merged commit b654d98 into elastic:master Sep 21, 2018
cbuescher pushed a commit that referenced this pull request Sep 21, 2018
This change adds the OneStatementPerLineCheck to our checkstyle precommit
checks. This rule restricts the number of statements per line to one. The
resoning behind this is that it is very difficult to read multiple statements on
one line. People seem to mostly use it in short lambdas and switch statements in
our code base, but just going through the changes already uncovered some actual
problems in randomization in test code, so I think its worth it.
kcm pushed a commit that referenced this pull request Oct 30, 2018
This change adds the OneStatementPerLineCheck to our checkstyle precommit
checks. This rule restricts the number of statements per line to one. The
resoning behind this is that it is very difficult to read multiple statements on
one line. People seem to mostly use it in short lambdas and switch statements in
our code base, but just going through the changes already uncovered some actual
problems in randomization in test code, so I think its worth it.
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Delivery/Build Build or test infrastructure >enhancement Team:Delivery Meta label for Delivery team v6.5.0 v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants