Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

review: refactor(*): Remove redundant supertypes #4369

Merged

Conversation

MartinWitt
Copy link
Collaborator

@MartinWitt MartinWitt commented Dec 19, 2021

Removed a lot of not needed supertypes in the code, where other supertypes already have the interface as supertype.

The following has changed in the code:
Removed interface java.io.Serializable from type spoon.reflect.cu.position.NoSourcePosition, because it's redundant
Removed interface spoon.reflect.declaration.CtTypeMember from type spoon.reflect.declaration.CtConstructor, because it's redundant
Removed interface spoon.reflect.declaration.CtTypeMember from type spoon.reflect.declaration.CtMethod, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.cu.position.BodyHolderSourcePositionImpl, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.cu.position.CompoundSourcePositionImpl, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.cu.position.DeclarationSourcePositionImpl, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.cu.position.SourcePositionImpl, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.declaration.CtElementImpl, because it's redundant
Removed interface spoon.reflect.visitor.Filter from type spoon.reflect.visitor.filter.AbstractReferenceFilter, because it's redundant

The following has changed in the code:
Removed interface java.io.Serializable from type spoon.reflect.cu.position.NoSourcePosition, because it's redundant
Removed interface spoon.reflect.declaration.CtTypeMember from type spoon.reflect.declaration.CtConstructor, because it's redundant
Removed interface spoon.reflect.declaration.CtTypeMember from type spoon.reflect.declaration.CtMethod, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.cu.position.BodyHolderSourcePositionImpl, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.cu.position.CompoundSourcePositionImpl, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.cu.position.DeclarationSourcePositionImpl, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.cu.position.SourcePositionImpl, because it's redundant
Removed interface java.io.Serializable from type spoon.support.reflect.declaration.CtElementImpl, because it's redundant
Removed interface spoon.reflect.visitor.Filter from type spoon.reflect.visitor.filter.AbstractReferenceFilter, because it's redundant
@MartinWitt MartinWitt force-pushed the refactor/automaticQodana/redundantSuperTypes branch from 4aee4e4 to 498d8b5 Compare December 23, 2021 13:13
@MartinWitt MartinWitt changed the title refactor(*): Remove redundant supertypes review: refactor(*): Remove redundant supertypes Dec 23, 2021
@monperrus
Copy link
Collaborator

Interesting, thanks @MartinWitt

In programming, explicitness is good. Here, the supertypes are explicit, and there is no risk of error because the compiler entirely checks for consistency.

So I'm not in favor of this PR because explicitness is good.

@MartinWitt
Copy link
Collaborator Author

I have a hard time in believing the information a programmer editing a class extending AbstractFilter<T> needs the information, that this class implements Filter<T>. But if we want really this explicitness, we should (again) declare them everywhere or nowhere. A codebase following any rule is better than no standard way.

@slarse
Copy link
Collaborator

slarse commented Jan 7, 2022

I have to agree with @MartinWitt here. This is both not done consistently, and there's also very little value in redeclaring superinterfaces/implemented interfaces. A modern IDE will quickly tell you all inherited/implemented interfaces, and Javadoc always lists all of them for any given class or interface. See for example NoSourcePosition.

So I vote for merging this.

@monperrus
Copy link
Collaborator

we should (again) declare them everywhere or nowhere

I disagree on this statement. We make an informed decision based on cost/benefit analysis. If removing or adding everywhere is too costly for too little benefits, it's not good. This is best-effort open source.

I have to agree with @MartinWitt here.

then go ahead :)

@MartinWitt
Copy link
Collaborator Author

Here is the link to the related sonar rule for documentation propose https://rules.sonarsource.com/java/RSPEC-1939

@slarse slarse merged commit 5f0a945 into INRIA:master Jan 14, 2022
@slarse
Copy link
Collaborator

slarse commented Jan 14, 2022

Thanks @MartinWitt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants