Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Issue 23654034: Add code style check error for using static_cast instead of toFoo function. (Closed)

Created:
7 years, 3 months ago by r.kasibhatla
Modified:
7 years, 3 months ago
CC:
blink-reviews, dglazkov+blink, eae+blinkwatch, ojan, aedla, ianbeer, Martin Barbella, abarth-chromium
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Add code style check error for using static_cast instead of toFoo function. We are migrating to new syntax of calling toFoo for any type of static_cast we do on Foo objects. We are adding to more and more classes toFoo helper functions, so we should ensure that the added helpers are actually *used* in the code. Currently, there is no enforcement on the same and through this change we are adding that style check which will fail any patch upload if we are not following toFoo style (if toFoo exists). As part of testing, executed check-webkit-style on all source files which still have static_cast<Foo*> code syntax. The script throws style error if we are using static_cast though we already have toFoo helper function. If toFoo is not yet defined, it doesn't throw any error right now (should that be changed?) BUG=None TEST=none; no behavior change; Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=158059

Patch Set 1 : #

Total comments: 10

Patch Set 2 : #

Total comments: 4

Patch Set 3 : #

Total comments: 1

Patch Set 4 : #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+121 lines, -9 lines) Patch
M Tools/Scripts/webkitpy/style/checkers/cpp.py View 1 2 3 2 chunks +112 lines, -5 lines 1 comment Download
M Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py View 1 1 chunk +9 lines, -4 lines 0 comments Download

Messages

Total messages: 25 (0 generated)
r.kasibhatla
PTAL.
7 years, 3 months ago (2013-09-14 18:20:37 UTC) #1
r.kasibhatla
PTAL
7 years, 3 months ago (2013-09-16 15:00:34 UTC) #2
eseidel
Inferno will be happy. :)
7 years, 3 months ago (2013-09-16 16:38:48 UTC) #3
eseidel
I'm OK with the idea. Ojan or dpranke are more our guardians of python these ...
7 years, 3 months ago (2013-09-16 16:39:37 UTC) #4
inferno
Wow! you are security team's best friend from now on :) We had this item ...
7 years, 3 months ago (2013-09-16 16:44:02 UTC) #5
inferno
https://codereview.chromium.org/23654034/diff/5001/Tools/Scripts/webkitpy/style/checkers/cpp.py File Tools/Scripts/webkitpy/style/checkers/cpp.py (right): https://codereview.chromium.org/23654034/diff/5001/Tools/Scripts/webkitpy/style/checkers/cpp.py#newcode3477 Tools/Scripts/webkitpy/style/checkers/cpp.py:3477: matched = search(r'\bstatic_cast<(\w+\s?\*+\s?)>', line) I think you should cover ...
7 years, 3 months ago (2013-09-16 16:56:46 UTC) #6
r.kasibhatla
On 2013/09/16 16:56:46, inferno wrote: > https://codereview.chromium.org/23654034/diff/5001/Tools/Scripts/webkitpy/style/checkers/cpp.py > File Tools/Scripts/webkitpy/style/checkers/cpp.py (right): > > https://codereview.chromium.org/23654034/diff/5001/Tools/Scripts/webkitpy/style/checkers/cpp.py#newcode3477 > ...
7 years, 3 months ago (2013-09-16 17:21:24 UTC) #7
inferno
7 years, 3 months ago (2013-09-17 00:02:44 UTC) #8
Dirk Pranke
Basically looks okay, python-wise. I noted a couple of nits, and inferno noted some other ...
7 years, 3 months ago (2013-09-17 01:54:55 UTC) #9
r.kasibhatla
https://codereview.chromium.org/23654034/diff/5001/Tools/Scripts/webkitpy/style/checkers/cpp.py File Tools/Scripts/webkitpy/style/checkers/cpp.py (right): https://codereview.chromium.org/23654034/diff/5001/Tools/Scripts/webkitpy/style/checkers/cpp.py#newcode3449 Tools/Scripts/webkitpy/style/checkers/cpp.py:3449: # List of all geninuine alternatives to static_cast. On ...
7 years, 3 months ago (2013-09-18 09:12:40 UTC) #10
inferno
lgtm https://codereview.chromium.org/23654034/diff/17001/Tools/Scripts/webkitpy/style/checkers/cpp.py File Tools/Scripts/webkitpy/style/checkers/cpp.py (right): https://codereview.chromium.org/23654034/diff/17001/Tools/Scripts/webkitpy/style/checkers/cpp.py#newcode3287 Tools/Scripts/webkitpy/style/checkers/cpp.py:3287: # Check for usage of static_cast<Classname*> or static_pointer_cast(). ...
7 years, 3 months ago (2013-09-18 16:46:04 UTC) #11
r.kasibhatla
Corrected for checking namespace::classname. PTAL. https://codereview.chromium.org/23654034/diff/17001/Tools/Scripts/webkitpy/style/checkers/cpp.py File Tools/Scripts/webkitpy/style/checkers/cpp.py (right): https://codereview.chromium.org/23654034/diff/17001/Tools/Scripts/webkitpy/style/checkers/cpp.py#newcode3287 Tools/Scripts/webkitpy/style/checkers/cpp.py:3287: # Check for usage ...
7 years, 3 months ago (2013-09-19 07:56:55 UTC) #12
inferno
https://codereview.chromium.org/23654034/diff/24001/Tools/Scripts/webkitpy/style/checkers/cpp.py File Tools/Scripts/webkitpy/style/checkers/cpp.py (right): https://codereview.chromium.org/23654034/diff/24001/Tools/Scripts/webkitpy/style/checkers/cpp.py#newcode3497 Tools/Scripts/webkitpy/style/checkers/cpp.py:3497: namespace_pos = class_name.find(':') Do a rfind and then class_name ...
7 years, 3 months ago (2013-09-19 14:32:44 UTC) #13
r.kasibhatla
Corrected the find.
7 years, 3 months ago (2013-09-19 20:04:37 UTC) #14
inferno
lgtm
7 years, 3 months ago (2013-09-19 20:16:28 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/r.kasibhatla@samsung.com/23654034/30001
7 years, 3 months ago (2013-09-19 20:16:51 UTC) #16
commit-bot: I haz the power
Change committed as 158059
7 years, 3 months ago (2013-09-19 22:17:56 UTC) #17
eseidel
This warning is not playing nice with the supplement-pattern code, which currently uses static_cast: https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/modules/navigationcontroller/NavigatorNavigationController.cpp&l=64 ...
7 years, 3 months ago (2013-09-20 18:35:24 UTC) #18
eseidel
I think we should consider turnign this check off for now. And running it over ...
7 years, 3 months ago (2013-09-20 18:38:06 UTC) #19
alecflett
On 2013/09/20 18:38:06, eseidel wrote: > I think we should consider turnign this check off ...
7 years, 3 months ago (2013-09-20 19:00:18 UTC) #20
aarya
On 2013/09/20 19:00:18, alecflett wrote: > On 2013/09/20 18:38:06, eseidel wrote: > > I think ...
7 years, 3 months ago (2013-09-20 19:06:15 UTC) #21
Dirk Pranke
I'm sorry, I didn't notice this before but this implementation and unit test has a ...
7 years, 3 months ago (2013-09-20 22:34:41 UTC) #22
yusukesuzuki
http://crbug.com/295673 is also related to this change.
7 years, 3 months ago (2013-09-22 12:21:06 UTC) #23
r.kasibhatla
On 2013/09/20 22:34:41, Dirk Pranke wrote: > I'm sorry, I didn't notice this before but ...
7 years, 3 months ago (2013-09-23 03:14:19 UTC) #24
r.kasibhatla
7 years, 3 months ago (2013-09-23 03:15:40 UTC) #25
Message was sent while issue was closed.
On 2013/09/20 19:06:15, aarya wrote:
> On 2013/09/20 19:00:18, alecflett wrote:
> > On 2013/09/20 18:38:06, eseidel wrote:
> > > I think we should consider turnign this check off for now.  And running it
> > over
> > > the entire codebase so we can understand where the current errors are
(there
> > > will be lots and we don't need to fix them all), but that will help inform
> us
> > of
> > > how much pain we're going to cause folks as they run into this trying to
> > modify
> > > existing code.
> > 
> > So I fixed one issue in https://codereview.chromium.org/24227005/ but as
> eseidel
> > writes, we should have tests for this.
> 
> Can we turn this into a warning for now, instead of a blocker ? That way, we
> will still prevent badness. I think Supplement might be the only case (since i
> encountered this while writing my bad cast catcher script in
> https://code.google.com/p/chromium/issues/detail?id=277650).

I am ok with that as long as reviewers are fine with it.
Just one question - how do make it as warning? Should it put in any specific
filter for doing that?

Powered by Google App Engine
This is Rietveld 408576698