Add check for redundant attributes (for now: redundant access specifier)#441
Conversation
|
I'd like to see a test for private:
public int a;
private: // should warn here |
src/analysis/redundant_attributes.d
Outdated
| { | ||
| auto token = attr.attribute; | ||
| addErrorMessage(token.line, token.column, KEY, | ||
| text("same access specifier used as defined on line ", |
There was a problem hiding this comment.
"access specifier" is inaccurate, it's called a visibility attribute.
If you add support for other attributes you'll have to think to use the correct term too.
src/analysis/redundant_attributes.d
Outdated
| void addAttribute(const Attribute attr) | ||
| { | ||
| removeOverwrite(attr); | ||
| if (checkAttribute(attr)) { |
There was a problem hiding this comment.
please don't blend the brace styles. same remark plenty of times !
|
small remark for the future: you can push the feature branch directly on dlang-community. It's easier for the reviewers to pull the branch on their clone. |
Added. Btw dlang/phobos#5477 contains all found instances in Phobos, but as mentioned it doesn't check all attributes (for now).
Fixed. Sorry.
Okay. I will do so next time. (or and then e.g. |
|
I suspected the current failure. It's on the test i asked you to add. |
Hmm are you sure? |
Right. Appveyor icon is still there ? |
I think GH isn't that smart - it will just be gone for new PRs ... |
fc7b5d7 to
e06ddb2
Compare
|
(rebased to master) |
|
Do you want to use this on phobos ASAP ? For me it's quite mergeable in the current state. Also you didn't touch it last 2 days, which means that it's also okay for you. |
I currently have other goals, but eventually at some point in the future, yes.
I eventually want to make it work with all kind of attributes, but unfortunately not in this month or in the foreseeable future. |
There's chance that the same check for all the attributes require much more work and will not be compatible with the current structure. IIRC for a |
When I started to write this check, it was mainly to avoid redundant access specifiers like:
However, I realized that it can work with any kind of attribute, e.g.
or
However, for now I lack the time to properly test all attribute combination, so I wrote generic code, but only enabled it for access specifier. It shouldn't be too hard to extend it to all attributes later.