eo
eo copied to clipboard
Fix checkstyle warnings for `PhDefault`
Split from #739
Refactor the class to pass all checkstyle checks. Current warnings:
[INFO] Checkstyle: src/main/java/org/eolang/PhDefault.java[44]: Class Data Abstraction Coupling is 10 (max allowed is 7) classes [AtAbsent, AtNamed, AtPhiSensitive, AtSimple, CachedPhi, Data.ToPhi, ExFailure, Indented, ThreadLocal, Vertices]. (ClassDataAbstractionCouplingCheck)
[INFO] Checkstyle: src/main/java/org/eolang/PhDefault.java[59]: Variable 'vertex' must be private and have accessor methods. (VisibilityModifierCheck)
[INFO] Checkstyle: src/main/java/org/eolang/PhDefault.java[116]: Return count is 2 (max allowed for non-void methods/lambdas is 1). (ReturnCountCheck)
[INFO] Checkstyle: src/main/java/org/eolang/PhDefault.java[216]: Return count is 2 (max allowed for non-void methods/lambdas is 1). (ReturnCountCheck)
[INFO] Checkstyle: src/main/java/org/eolang/PhDefault.java[274]: Return count is 2 (max allowed for non-void methods/lambdas is 1). (ReturnCountCheck)
[INFO] Checkstyle: src/main/java/org/eolang/PhDefault.java[295]: Avoid inline conditionals. (AvoidInlineConditionalsCheck)
@Graur can i try to solve this one?
@l3r8yJ Sure, go ahead
@Graur there are a few more warnings about checkstyle, but not the ones described in the issue
[INFO] PMD: src/main/java/org/eolang/PhDefault.java[45-316]: This class has too many methods, consider refactoring it. (TooManyMethods)
[INFO] PMD: src/main/java/org/eolang/PhDefault.java[45-316]: Avoid doing field initialization outside constructor. (ConstructorShouldDoInitialization)
[INFO] PMD: src/main/java/org/eolang/PhDefault.java[98-98]: Only field initialization or call to other constructors in a constructor. (ConstructorOnlyInitializesOrCallOtherConstructors)
[INFO] PMD: src/main/java/org/eolang/PhDefault.java[99-99]: Only field initialization or call to other constructors in a constructor. (ConstructorOnlyInitializesOrCallOtherConstructors)
@l3r8yJ These are PMD checks, not a checkstyle. If you can fix them, please do so.
@Graur okay, i’ll fix them all
@mximp is it still a problem or we can close?
@l3r8yJ is there anything to fix?
@mximp my work was temporarily interrupted by circumstances, but now I am back at it
@mximp there are only 2 warnings left, but I don't really see how I can change them since they affect most of the project.
[INFO] Checkstyle: src/main/java/org/eolang/PhDefault.java[45]: Class Data Abstraction Coupling is 11 (max allowed is 7) classes [AtAbsent, AtNamed, AtPhiSensitive, AtSafe, AtSimple, CachedPhi, Data.ToPhi, ExFailure, Indented, ThreadLocal, Vertices]. (ClassDataAbstractionCouplingCheck)
[INFO] Checkstyle: src/main/java/org/eolang/PhDefault.java[65]: Variable 'vertex' must be private and have accessor methods. (VisibilityModifierCheck)
If I change protected to private the descendants cannot use it or can the implementation of the inheritors also be changed?
@l3r8yJ VTX can be made private and new method is exposed in PhDefault: protected void vertexFor(Object value). The method can be used in Data.Value:
public Value(final T value) {
super(Phi.Φ);
this.val = value;
this.vertexFor(value);
}
@mximp yes, already did it in 630cfc3
@l3r8yJ what is pull request for the changes?
@mximp i'll send it when came back from university
@mximp @l3r8yJ what's up with this one?
@l3r8yJ any PR linked to this issue?
@mximp it's here