eo icon indicating copy to clipboard operation
eo copied to clipboard

Fix checkstyle warnings for `PhDefault`

Open mximp opened this issue 3 years ago • 13 comments

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)

mximp avatar Jul 18 '22 08:07 mximp

@Graur can i try to solve this one?

l3r8yJ avatar Aug 01 '22 18:08 l3r8yJ

@l3r8yJ Sure, go ahead

Graur avatar Aug 01 '22 21:08 Graur

@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 avatar Aug 01 '22 22:08 l3r8yJ

@l3r8yJ These are PMD checks, not a checkstyle. If you can fix them, please do so.

Graur avatar Aug 02 '22 05:08 Graur

@Graur okay, i’ll fix them all

l3r8yJ avatar Aug 02 '22 06:08 l3r8yJ

@mximp is it still a problem or we can close?

yegor256 avatar Aug 23 '22 19:08 yegor256

@l3r8yJ is there anything to fix?

mximp avatar Aug 24 '22 12:08 mximp

@mximp my work was temporarily interrupted by circumstances, but now I am back at it

l3r8yJ avatar Aug 27 '22 15:08 l3r8yJ

@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 avatar Sep 03 '22 17:09 l3r8yJ

@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 avatar Sep 05 '22 09:09 mximp

@mximp yes, already did it in 630cfc3

l3r8yJ avatar Sep 05 '22 10:09 l3r8yJ

@l3r8yJ what is pull request for the changes?

mximp avatar Sep 05 '22 11:09 mximp

@mximp i'll send it when came back from university

l3r8yJ avatar Sep 05 '22 12:09 l3r8yJ

@mximp @l3r8yJ what's up with this one?

yegor256 avatar Nov 13 '22 04:11 yegor256

@l3r8yJ any PR linked to this issue?

mximp avatar Nov 16 '22 08:11 mximp

@mximp it's here

l3r8yJ avatar Nov 16 '22 17:11 l3r8yJ