-
Notifications
You must be signed in to change notification settings - Fork 142
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
#3160 Enable PMD for eo-runime
#3171
Changes from 18 commits
68f7bb9
931958c
22fa0a4
8bf5e84
8e82e95
029b7b2
aa4542d
db2d4d5
cf5db6a
33b264a
ff1c2ed
1286ee0
5f15eb3
058015a
380976e
b2a049c
d3a8376
f4a0dd2
8f827f3
b63ec99
88d82de
2e6fade
56c2ee1
72ce8c8
df95e60
ba2a9e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,11 +35,13 @@ | |
* @since 0.36 | ||
*/ | ||
@Versionized | ||
@SuppressWarnings("PMD.TooManyMethods") | ||
public final class PhTraced implements Phi { | ||
|
||
/** | ||
* Name of property that responsible for keeping max depth. | ||
*/ | ||
@SuppressWarnings("PMD.LongVariable") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @c71n93 why can't you just make the name shorter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yegor256 Because this variable means "maximum cage recursion depth". As for me the shortest name for this variable is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @c71n93 how about |
||
public static final String | ||
MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME = "EO_MAX_CAGE_RECURSION_DEPTH"; | ||
|
||
|
@@ -58,7 +60,7 @@ public final class PhTraced implements Phi { | |
/** | ||
* Locator of encaged object. | ||
*/ | ||
private final Integer locator; | ||
private final Integer locatr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @c71n93 what was wrong with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maxonfjvipon it repeats the method name (prohibited by PMD) |
||
|
||
/** | ||
* Max depth of cage recursion. | ||
|
@@ -88,13 +90,13 @@ public PhTraced(final Phi object, final Integer locator) { | |
*/ | ||
public PhTraced(final Phi object, final Integer locator, final int depth) { | ||
this.object = object; | ||
this.locator = locator; | ||
this.locatr = locator; | ||
this.depth = depth; | ||
} | ||
|
||
@Override | ||
public Phi copy() { | ||
return new PhTraced(this.object.copy(), this.locator); | ||
return new PhTraced(this.object.copy(), this.locatr); | ||
} | ||
|
||
@Override | ||
|
@@ -188,13 +190,13 @@ public T get() { | |
*/ | ||
private Integer incrementCageCounter() { | ||
return PhTraced.DATAIZING_CAGES.get().compute( | ||
PhTraced.this.locator, (key, counter) -> { | ||
PhTraced.this.locatr, (key, counter) -> { | ||
final int ret = this.incremented(counter); | ||
if (ret > PhTraced.this.depth) { | ||
throw new ExFailure( | ||
"The cage %s with locator %d has reached the maximum nesting depth = %d", | ||
PhTraced.this.object, | ||
PhTraced.this.locator, | ||
PhTraced.this.locatr, | ||
PhTraced.this.depth | ||
); | ||
} | ||
|
@@ -229,11 +231,11 @@ private void decrementCageCounter(final int incremented) { | |
final int decremented = incremented - 1; | ||
if (decremented == 0) { | ||
PhTraced.DATAIZING_CAGES.get().remove( | ||
PhTraced.this.locator | ||
PhTraced.this.locatr | ||
); | ||
} else { | ||
PhTraced.DATAIZING_CAGES.get().put( | ||
PhTraced.this.locator, decremented | ||
PhTraced.this.locatr, decremented | ||
); | ||
} | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maxonfjvipon do we need this class? It never used now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @c71n93 we don't need it |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ public final class PhWrite extends PhDefault implements Atom { | |
* @param attr Attribute name | ||
* @param ret Return value function | ||
*/ | ||
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @c71n93 maybe we can rewrite the code instead of suppressing the warning? |
||
public PhWrite( | ||
final String attr, | ||
final Function<Phi, Phi> ret | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 @maxonfjvipon maybe we can move this class to
eo-runtime/src/test/java/EOorg/EOeolang/
? (it uses only there)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@c71n93 I believe it should stay in
org.eolang
since it's kind of part of common runtime object which are used for building the concrete ones