New issue
Advanced search Search tips

Issue 740162 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 26
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug

Blocked on:
issue 768576
issue 768586



Sign in to add a comment

git cl format and checkstyle don't agree on generics formatting

Project Member Reported by dgn@chromium.org, Jul 7 2017

Issue description

$ git cl presubmit -u
Running presubmit upload checks ...

** Presubmit Warnings **
The src directory requires source formatting. Please run git cl format .

** Presubmit ERRORS **
  chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java:808:65: GenericWhitespace '>' is followed by whitespace.


$ git cl format && git diff
 @@ -805,6 +805,6 @@ private static void verifyAction(
          verify(suggestionsSource,
                  (action == ContentSuggestionsAdditionalAction.FETCH ? times(1) : never()))
                  .fetchSuggestions(anyInt(), any(String[].class),
 -                        Mockito.<Callback<List<SnippetArticle>>> any());
 +                        Mockito.< Callback < List<SnippetArticle>>> any());
      }
  }


$ git commit --amend -a -C HEAD && git cl presubmit -u
Running presubmit upload checks ...

** Presubmit ERRORS **
  chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java:808:34: GenericWhitespace '<' is followed by whitespace.
  chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java:808:43: GenericWhitespace '<' is preceded with whitespace.
  chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java:808:45: GenericWhitespace '<' is followed by whitespace.
  chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java:808:68: GenericWhitespace '>' is followed by whitespace.



 
Components: Build Infra>SDK
We've seen a few of these over the past month or so (https://groups.google.com/a/chromium.org/d/msg/chromium-dev/7Zm1Z49TV7U/3LfkaujOCgAJ)

my suspicion is that we should just defer to git cl format & rip out the other style checks we do in presubmit, though I can't say I'm particularly fond of that GenericWhitespace change.
Cc: -aga...@chromium.org
Components: -Infra>SDK Infra>Client>Android
Yep, I agree with jbudorick, this needs to be fixed by Android folks.

The GenericWhitespace messages are android-specific, and are generated by checkstyle, which is pulled in via DEPS: https://cs.chromium.org/chromium/src/third_party/leakcanary/src/checkstyle.xml?q=GenericWhitespace&sq=package:chromium&dr=C

If they disagree with git-cl-format (which just calls through to clang-format, also pulled in via chromium DEPS https://cs.chromium.org/chromium/src/buildtools/clang_format/), then that needs to be fixed by the maintainers of checkstyle and/or its configuration.

Comment 3 by dgn@chromium.org, Jul 10 2017

In this specific case, I'd say clang-format is wrong, probably mixing up generics usage with comparison operators. At least that's not a usual Java style and checkstyle is right to flag it.

But yes, having the two systems is frustrating. Maybe the fix would be just to remove the clang-format check from submit checks? It would only run at upload time so the CL author can choose to override that? I'd say checkstyle targets Java primarily unlike clang-format, so it might be correct more often and could keep running on the bots.

Comment 4 by thakis@chromium.org, Sep 25 2017

Blockedon: 768576

Comment 5 by thakis@chromium.org, Sep 26 2017

I debugged this a bit, I think the root cause is that clang-format sees the >>> and figures it's a logical right shift op and then can't match that one token to the three < tokens. If the input is 

  void foo() { Mockito.<Callback<List<SnippetArticle> > > any(); }

then the output is correct O_o

Looking more…

Comment 6 by thakis@chromium.org, Sep 26 2017

Turns out this is a recent regression (from a patch that I reviewed shame shame shame). Fix attempt: https://reviews.llvm.org/D38291

Comment 7 by thakis@chromium.org, Sep 27 2017

Blockedon: 768586
Owner: thakis@chromium.org
Status: Started (was: Untriaged)
http://llvm.org/viewvc/llvm-project?view=revision&revision=314325
Components: Infra>Client>Chrome
Moving Infra>Client>Android -> Infra>Client>Chrome+OS=Android
Components: -Infra>Client>Android
Status: Fixed (was: Started)
A clang-format with the fix got deployed on Nov 21 2018.

Sign in to add a comment