Skip to content

Commit

Permalink
Merge pull request #33 from santanusinha/sonar_Cleanup
Browse files Browse the repository at this point in the history
Some cleanups for sonar
  • Loading branch information
r0goyal authored Aug 21, 2023
2 parents 8a784ae + b3a2087 commit 9c1efe6
Show file tree
Hide file tree
Showing 20 changed files with 134 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=santanusinha_hope
- name: Create dependency tree
run: mvn dependency:tree -DoutputFile=dependencies.txt
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Comitting files changed by Github Actions
Expand Down
14 changes: 7 additions & 7 deletions dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
io.appform.hope:hope:pom:2.0.1
io.appform.hope:hope:pom:2.0.3
+- org.openjdk.jmh:jmh-core:jar:1.35:test
| +- net.sf.jopt-simple:jopt-simple:jar:5.0.4:test
| \- org.apache.commons:commons-math3:jar:3.2:test
Expand All @@ -11,14 +11,14 @@ io.appform.hope:hope:pom:2.0.1
| +- org.checkerframework:checker-qual:jar:3.12.0:provided
| +- com.google.errorprone:error_prone_annotations:jar:2.7.1:provided
| \- com.google.j2objc:j2objc-annotations:jar:1.3:provided
+- com.fasterxml.jackson.core:jackson-core:jar:2.13.1:compile
+- com.fasterxml.jackson.core:jackson-databind:jar:2.13.1:compile
| \- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.1:compile
+- com.fasterxml.jackson.core:jackson-core:jar:2.13.4:compile
+- com.fasterxml.jackson.core:jackson-databind:jar:2.13.4.1:compile
| \- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.4:compile
+- com.jayway.jsonpath:json-path:jar:2.7.0:compile
| +- net.minidev:json-smart:jar:2.4.7:compile
| | \- net.minidev:accessors-smart:jar:2.4.7:compile
| | \- org.ow2.asm:asm:jar:9.1:compile
| \- org.slf4j:slf4j-api:jar:1.7.33:compile
+- net.minidev:json-smart:jar:2.4.11:compile
| \- net.minidev:accessors-smart:jar:2.4.11:compile
| \- org.ow2.asm:asm:jar:9.3:compile
+- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
| +- org.opentest4j:opentest4j:jar:1.2.0:test
| +- org.junit.platform:junit-platform-commons:jar:1.8.2:test
Expand Down
14 changes: 7 additions & 7 deletions hope-core/dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
io.appform.hope:hope-core:jar:2.0.1
io.appform.hope:hope-core:jar:2.0.3
+- org.reflections:reflections:jar:0.9.12:compile
| \- org.javassist:javassist:jar:3.26.0-GA:compile
+- org.openjdk.jmh:jmh-core:jar:1.35:test
Expand All @@ -13,14 +13,14 @@ io.appform.hope:hope-core:jar:2.0.1
| +- org.checkerframework:checker-qual:jar:3.12.0:provided
| +- com.google.errorprone:error_prone_annotations:jar:2.7.1:provided
| \- com.google.j2objc:j2objc-annotations:jar:1.3:provided
+- com.fasterxml.jackson.core:jackson-core:jar:2.13.1:compile
+- com.fasterxml.jackson.core:jackson-databind:jar:2.13.1:compile
| \- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.1:compile
+- com.fasterxml.jackson.core:jackson-core:jar:2.13.4:compile
+- com.fasterxml.jackson.core:jackson-databind:jar:2.13.4.1:compile
| \- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.4:compile
+- com.jayway.jsonpath:json-path:jar:2.7.0:compile
| +- net.minidev:json-smart:jar:2.4.7:compile
| | \- net.minidev:accessors-smart:jar:2.4.7:compile
| | \- org.ow2.asm:asm:jar:9.1:compile
| \- org.slf4j:slf4j-api:jar:1.7.33:compile
+- net.minidev:json-smart:jar:2.4.11:compile
| \- net.minidev:accessors-smart:jar:2.4.11:compile
| \- org.ow2.asm:asm:jar:9.3:compile
+- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
| +- org.opentest4j:opentest4j:jar:1.2.0:test
| +- org.junit.platform:junit-platform-commons:jar:1.8.2:test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class BinaryOperator<T extends Value> extends Evaluatable {
protected final T lhs;
protected final T rhs;

public BinaryOperator(T lhs, T rhs) {
protected BinaryOperator(T lhs, T rhs) {
this.lhs = lhs;
this.rhs = rhs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public abstract class HopeException extends RuntimeException {
public HopeException(String message) {
protected HopeException(String message) {
super(message);
}

public HopeException(String message, Throwable cause) {
protected HopeException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public synchronized void discover(List<String> packages) {
.addAll(packages.stream()
.flatMap(packagePath -> ClasspathHelper.forPackage(packagePath)
.stream())
.collect(Collectors.toList()))
.toList())
.build();
Reflections reflections = new Reflections(
new ConfigurationBuilder()
Expand Down Expand Up @@ -133,9 +133,6 @@ private static List<ConstructorMeta> constructors(Class<? extends HopeFunction>
final Constructor<? extends HopeFunction>[] declaredConstructors
= (Constructor<? extends HopeFunction>[]) type.getDeclaredConstructors();
FunctionImplementation annotation = type.getAnnotation(FunctionImplementation.class);
/* Preconditions.checkArgument(
declaredConstructors != null && declaredConstructors.length == 1,
"Function " + annotation.value() + " must have only one constructor");*/
return Arrays.stream(declaredConstructors)
.map(declaredConstructor -> {
final Class<?>[] declaredParamTypes = declaredConstructor
Expand All @@ -145,13 +142,13 @@ private static List<ConstructorMeta> constructors(Class<? extends HopeFunction>
? parameterType.getComponentType()
.isAssignableFrom(Value.class)
: parameterType.isAssignableFrom(Value.class))
.collect(Collectors.toList());
.toList();
Preconditions.checkArgument(
paramTypes.size() == declaredParamTypes.length,
"Non value parameter types declared for constructor in function '"
+ annotation.value() + "'. Param types: " + Arrays.stream(declaredParamTypes)
.map(Class::getSimpleName)
.collect(Collectors.toList()));
.toList());
final boolean variantArgs = paramTypes.stream()
.anyMatch(Class::isArray);
Preconditions.checkArgument(!variantArgs || paramTypes.size() == 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
* Returns {@link NumericValue} length of provided evaluated {@link StringValue} parameter.
*/
@FunctionImplementation("str.len")
public class Length extends HopeFunction {
public class Length extends HopeFunction<NumericValue> {
private final Value arg;

public Length(Value arg) {
this.arg = arg;
}

@Override
public Value apply(Evaluator.EvaluationContext evaluationContext) {
public NumericValue apply(Evaluator.EvaluationContext evaluationContext) {
return new NumericValue((double)Converters.stringValue(evaluationContext, arg, "").length());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
* Returns lower case {@link StringValue} of provided {@link StringValue} parameter.
*/
@FunctionImplementation("str.lower")
public class LowerCase extends HopeFunction {
public class LowerCase extends HopeFunction<StringValue> {
private final Value arg;

public LowerCase(Value arg) {
this.arg = arg;
}

@Override
public Value apply(Evaluator.EvaluationContext evaluationContext) {
public StringValue apply(Evaluator.EvaluationContext evaluationContext) {
return new StringValue(Converters.stringValue(evaluationContext, arg, "").toLowerCase());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* to {@link io.appform.hope.core.values.NumericValue} end (exclusive).
*/
@FunctionImplementation("str.substr")
public class SubStr extends HopeFunction {
public class SubStr extends HopeFunction<StringValue> {
private final Value arg;
private final Value start;
private final Value end;
Expand All @@ -43,7 +43,7 @@ public SubStr(Value arg, Value start, Value end) {
}

@Override
public Value apply(Evaluator.EvaluationContext evaluationContext) {
public StringValue apply(Evaluator.EvaluationContext evaluationContext) {
final String argValue = Converters.stringValue(evaluationContext, arg, "");
int startIndex = Converters.numericValue(evaluationContext, start, 0).intValue();
final int endIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
* Returns upper case {@link StringValue} of provided {@link StringValue} parameter.
*/
@FunctionImplementation("str.upper")
public class UpperCase extends HopeFunction {
public class UpperCase extends HopeFunction<StringValue> {
private final Value arg;

public UpperCase(Value arg) {
this.arg = arg;
}

@Override
public Value apply(Evaluator.EvaluationContext evaluationContext) {
public StringValue apply(Evaluator.EvaluationContext evaluationContext) {
return new StringValue(Converters.stringValue(evaluationContext, arg, "").toUpperCase());
}
}
Loading

0 comments on commit 9c1efe6

Please sign in to comment.