Re: [DISCUSS] Automation for Java code formatting

2018-06-28 Thread Kenneth Knowles
It is done. In the same PR I wiped out checkstyle rules that became redundant. There are still quite a few. On Thu, Jun 28, 2018 at 10:02 AM Udi Meiri wrote: > Python already has lint checks: :beam-sdks-python:lint > There are autoformatting tools, which we don't use AFAIK: >

Re: [DISCUSS] Automation for Java code formatting

2018-06-28 Thread Udi Meiri
Python already has lint checks: :beam-sdks-python:lint There are autoformatting tools, which we don't use AFAIK: https://github.com/myint/autoflake https://github.com/hhatto/autopep8 On Thu, Jun 28, 2018 at 12:31 AM Daniel Kulp wrote: > > > On Jun 28, 2018, at 6:01 AM, Kenneth Knowles wrote:

Re: [DISCUSS] Automation for Java code formatting

2018-06-28 Thread Reuven Lax
I don't think so. Checkstyle checks for a number of things beyond simple formatting issues, (i.e. redundant imports). On Thu, Jun 28, 2018 at 12:31 AM Daniel Kulp wrote: > > > On Jun 28, 2018, at 6:01 AM, Kenneth Knowles wrote: > > So, there are a few modes of checkstyle failure that can be

Re: [DISCUSS] Automation for Java code formatting

2018-06-28 Thread Daniel Kulp
> On Jun 28, 2018, at 6:01 AM, Kenneth Knowles wrote: > > So, there are a few modes of checkstyle failure that can be induced by this: > > - lines get too long because of wrap & indent logic > - a lot of our HTML is actually already broken and doesn't have tags > where it should; spotless

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Kenneth Knowles
So, there are a few modes of checkstyle failure that can be induced by this: - lines get too long because of wrap & indent logic - a lot of our HTML is actually already broken and doesn't have tags where it should; spotless adds a blank line which makes checkstyle notice the errors I think

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Robert Burke
+1! Given this is the recommended default for Go projects (with it's own gofmt tool) I'm for similar tooling for this in other languages. I suspect we can add Gradle command to run gofmt over the go code too for a consistent hook to run for beam code. It would save folks from needing to set up

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Jean-Baptiste Onofré
+1 I already used it in SQL module and it's great. It makes sense to apply on all modules. Thanks ! Regards JB Le 27 juin 2018 à 12:15, à 12:15, Kenneth Knowles a écrit: >Hi all, > >I like readable code, but I don't like formatting it myself. And I >_really_ >don't like discussing in code

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Kenneth Knowles
OK, I opened https://github.com/apache/beam/pull/5797. This thread is still less than a day, so there's no commitment yet. There's no big hurry - I can always discard the autoformat and rerun it. I'm sure there will always be conflicts so I will just have to rerun it and merge at some quiet period

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Daniel Oliveira
+1 I'll throw in my support for auto-formatting, especially if the entire project is auto-formatted in advance. On Wed, Jun 27, 2018 at 10:53 AM Huygaa Batsaikhan wrote: > +1. Global auto-formatting is cool! > > On Wed, Jun 27, 2018 at 10:17 AM Kenneth Knowles wrote: > >> I just mean that

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Kenneth Knowles
I just mean that because of how the tool works. But I guess if there were discretion then two different people could end up with autoformatting that disagrees, so again you get lines in the PR diff that aren't real changes. Kenn On Wed, Jun 27, 2018 at 10:16 AM Raghu Angadi wrote: > On Wed,

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Raghu Angadi
On Wed, Jun 27, 2018 at 10:13 AM Kenneth Knowles wrote: > Nope! No discretion allowed :-) > +1. Fair enough! > > On Wed, Jun 27, 2018 at 9:57 AM Raghu Angadi wrote: > >> +1. >> >> Wondering if it can be configured to reformat only what we care most >> about (2 space indentation etc),

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Kenneth Knowles
Nope! No discretion allowed :-) On Wed, Jun 27, 2018 at 9:57 AM Raghu Angadi wrote: > +1. > > Wondering if it can be configured to reformat only what we care most about > (2 space indentation etc), allowing some discretion on the edges. An > example of inconsistent formatting that ends up in my

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Raghu Angadi
+1. Wondering if it can be configured to reformat only what we care most about (2 space indentation etc), allowing some discretion on the edges. An example of inconsistent formatting that ends up in my code: --- anObject.someLongMethodName(arg_number_1,

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Lukasz Cwik
It wasn't clear to me that the intent was to autoformat all the code from the proposal initially. If thats the case, then the delta is quite small typically. Also, it would be easier if we recommended to users to run run "./gradlew spotlessApply" which will run spotless on all modules. On Wed,

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Rafael Fernandez
On Wed, Jun 27, 2018 at 9:31 AM Kenneth Knowles wrote: > Luke: the proposal here solves exactly what you are talking about. > > The problem you describe happens when the PR author uses autoformat but > the baseline is not already autoformatted. What I am proposing is to make > sure the baseline

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Kenneth Knowles
Luke: the proposal here solves exactly what you are talking about. The problem you describe happens when the PR author uses autoformat but the baseline is not already autoformatted. What I am proposing is to make sure the baseline is already autoformatted, so PRs never have extraneous formatting

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Andrew Pilloud
I agree that PRs with formatting changes are impossible to review, but I think that is exactly what this is trying to avoid. If this is run nightly, some contributors will still autoformat their PRs and have a bunch of unrelated changes in the diff. If the code is always well formatted (and that

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Rafael Fernandez
Luke: Anything that helps contributors and reviewers work better together - +1! :D On Wed, Jun 27, 2018 at 9:04 AM Lukasz Cwik wrote: > If spotless is run against a PR that is already well formatted its a > non-issue as the formatting changes are usually related to the change but I > have

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Lukasz Cwik
If spotless is run against a PR that is already well formatted its a non-issue as the formatting changes are usually related to the change but I have reviewed a few PRs that have 100s of lines of formatting change which really obfuscates the work. Instead of asking contributors to run spotless,

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Kenneth Knowles
Good points, Dan. Checkstyle will still run, but just focused on the things that go beyond format. Kenn On Wed, Jun 27, 2018 at 8:03 AM Etienne Chauchot wrote: > +1 ! > It's my custom to avoid reformatting to spare meaningless diff burden to > the reviewer. Now it will be over, thanks. > >

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Etienne Chauchot
+1 !It's my custom to avoid reformatting to spare meaningless diff burden to the reviewer. Now it will be over, thanks. Etienne Le mardi 26 juin 2018 à 21:15 -0700, Kenneth Knowles a écrit : > Hi all, > I like readable code, but I don't like formatting it myself. And I _really_ > don't like

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Daniel Kulp
I’m +1 to the idea of using something to handle the auto-formatting of code. HOWEVER, I want to make it clear that this will likely NOT remove checkstyle from the builds as there are things that checkstyle checks that aren’t part of this. Variable names, type names, javadoc things, etc….

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Ismaël Mejía
++1 - This solves the big mismatch of autoformatting using eclipse's google java style and the google-java-format plugin that makes a common source of unneeded diffs part of the reviews. - The spotless plugin makes this trivial to do and uniform. We need to update the instructions on formatting

Re: [DISCUSS] Automation for Java code formatting

2018-06-27 Thread Łukasz Gajowy
+1 to automating this with Gradle and never have problems with formatting/forgetting about it again! :) śr., 27 cze 2018 o 07:40 Tim Robertson napisał(a): > ++1 > > > On Wed, Jun 27, 2018 at 7:36 AM, Ahmet Altay wrote: > >> +1 >> >> This is great idea. Does anyone know a similar tool for

Re: [DISCUSS] Automation for Java code formatting

2018-06-26 Thread Tim Robertson
++1 On Wed, Jun 27, 2018 at 7:36 AM, Ahmet Altay wrote: > +1 > > This is great idea. Does anyone know a similar tool for python? I believe > go already has this as part of its tools with go fmt. > > > On Tue, Jun 26, 2018 at 9:55 PM, Ankur Goenka wrote: > >> +1 >> >> Intellij can help but

Re: [DISCUSS] Automation for Java code formatting

2018-06-26 Thread Ahmet Altay
+1 This is great idea. Does anyone know a similar tool for python? I believe go already has this as part of its tools with go fmt. On Tue, Jun 26, 2018 at 9:55 PM, Ankur Goenka wrote: > +1 > > Intellij can help but still formatting is an additional thing to keep in > mind. Enabling auto

Re: [DISCUSS] Automation for Java code formatting

2018-06-26 Thread Ankur Goenka
+1 Intellij can help but still formatting is an additional thing to keep in mind. Enabling auto formatting at gradle level will remove this additional thing to keep in mind. On Tue, Jun 26, 2018 at 9:49 PM Eugene Kirpichov wrote: > +1! > > In some cases the temptation to format code manually

Re: [DISCUSS] Automation for Java code formatting

2018-06-26 Thread Eugene Kirpichov
+1! In some cases the temptation to format code manually can be quite strong, but the ease of just re-running the formatter after any change (especially after global changes like class/method renames) overweighs it. I lost count of the times when I wasted a precommit because some line became >100

Re: [DISCUSS] Automation for Java code formatting

2018-06-26 Thread Rafael Fernandez
+1! Remove guesswork :D On Tue, Jun 26, 2018 at 9:15 PM Kenneth Knowles wrote: > Hi all, > > I like readable code, but I don't like formatting it myself. And I > _really_ don't like discussing in code review. "Spotless" [1] can enforce - > and automatically apply - automatic formatting for

[DISCUSS] Automation for Java code formatting

2018-06-26 Thread Kenneth Knowles
Hi all, I like readable code, but I don't like formatting it myself. And I _really_ don't like discussing in code review. "Spotless" [1] can enforce - and automatically apply - automatic formatting for Java, Groovy, and some others. This is not about style or wanting a particular layout. This is