Skip to content

Commit

Permalink
PHEE 307,419 Applied formatting and styling (#50)
Browse files Browse the repository at this point in the history
* PHEE 307,419 Applied formatting and styling

* Resolved all errors for checkstyle and errorprone

* Updated the CI changes for checkstyle command
  • Loading branch information
dhruvsonagara authored Oct 20, 2023
1 parent aa261d3 commit a27cb1f
Show file tree
Hide file tree
Showing 72 changed files with 2,791 additions and 2,099 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: 2.1
executors:
docker-executor:
docker:
- image: circleci/openjdk:13.0-buster-node-browsers-legacy
- image: circleci/openjdk:17.0-buster-node-browsers-legacy

jobs:
build_and_push_tag_image:
executor: docker-executor
environment:
JVM_OPTS: -Xmx512m
TERM: dumb
TERM: dumb
GITHUB_TOKEN: ${GITHUB_TOKEN} # Add the GitHub token as an environment variable

steps:
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
docker push "openmf/ph-ee-connector-ams-mifos:$IMAGE_TAG"
# when: always # The job will be executed even if there's no match for the tag filter

build_and_push_latest_image:
executor: docker-executor
environment:
Expand All @@ -55,7 +55,8 @@ jobs:
name: Build Docker image
command: |
IMAGE_TAG=$CIRCLE_TAG
./gradlew bootJar
./gradlew checkstyleMain
./gradlew clean bootJar
docker build -t openmf/ph-ee-connector-ams-mifos:latest .
# Log in to DockerHub using environment variables
Expand All @@ -66,7 +67,7 @@ jobs:
# Push the Docker image to DockerHub
- run:
name: Push Docker image to DockerHub
command: docker push openmf/ph-ee-connector-ams-mifos:latest
command: docker push openmf/ph-ee-connector-ams-mifos:latest

workflows:
version: 2
Expand All @@ -81,4 +82,3 @@ workflows:
- build_and_push_latest_image:
context:
- DOCKER

2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Please make sure these boxes are checked before submitting your pull request - thanks!

- [ ] Design related bullet points or design document link related to this PR added in the description above.
- [ ] Design related bullet points or design document link related to this PR added in the description above.

- [ ] Updated corresponding Postman Collection or Api documentation for the changes in this PR.

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ph-ee-connector-ams-mifos
Payment Hub Enterprise Edition connector for local AMS.
By default local quote is disabled and only empty Zeebe workers are started.
Payment Hub Enterprise Edition connector for local AMS.
By default local quote is disabled and only empty Zeebe workers are started.
Currently supported AMS backends: (configure corresponding yml files to modify properties)
* Fineract 1.2 -> use spring profile fin12

Expand Down Expand Up @@ -29,4 +29,4 @@ Currently supported AMS backends: (configure corresponding yml files to modify p
| | payee-deposit-transfer-dfspId | international-remittance-payee-process-DFSPID.bpmn |
| direct:get-party | party-lookup-local-dfspId | debit-party-process-DFSPID.bpmn,gsma-bill-payment.bpmn,gsma-inttransfer-payer.bpmn,gsma-link-based-transfer.bpmn,gsma-p2p-wo-local-quote.bpmn,gsma-p2p.bpmn,payee-party-lookup-DFSPID.bpmn |
| direct:send-local-quote | payer-local-quote-dfspId | gsma-p2p.bpmn,payer-fund-transfer-DFSPID.bpmn,payer-fund-transfer-terminate-DFSPID.bpmn,orchestration/feel/payer-transaction-request-DFSPID.bpmn |
| | payee-quote-dfspId | gsma-payee-process.bpmn,payee-quote-transfer-DFSPID.bpmn |
| | payee-quote-dfspId | gsma-payee-process.bpmn,payee-quote-transfer-DFSPID.bpmn |
229 changes: 227 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ plugins {
id 'java'
id 'maven-publish'
id 'eclipse'
id 'org.springframework.boot' version '2.1.9.RELEASE'
id 'checkstyle'
id 'org.springframework.boot' version '2.6.2'
id 'com.diffplug.spotless' version '6.19.0'
id 'net.ltgt.errorprone' version '3.1.0'
}

repositories {
Expand All @@ -20,6 +23,28 @@ repositories {
}
}

apply plugin:'com.diffplug.spotless'
spotless {
format 'misc', {
target '**/*.md', '**/*.properties', '**/.gitignore', '**/.openapi-generator-ignore', '**/*.yml', '**/*.xml', '**/**.json', '**/*.sql'
targetExclude '**/build/**', '**/bin/**', '**/.settings/**', '**/.idea/**', '**/.gradle/**', '**/gradlew.bat', '**/licenses/**', '**/banner.txt', '.vscode/**'
indentWithSpaces(4)
endWithNewline()
trimTrailingWhitespace()
}

groovyGradle {
target '*.gradle', '**/*.gradle'
targetExclude '**/build/**'
greclipse()
indentWithSpaces(4)
endWithNewline()
trimTrailingWhitespace()
}

lineEndings 'UNIX'
}

dependencies {
implementation 'org.mifos:ph-ee-connector-common:1.5.1-SNAPSHOT'
implementation 'com.sun.xml.ws:jaxws-ri:2.3.2'
Expand All @@ -39,6 +64,8 @@ dependencies {
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation group: 'org.springframework', name: 'spring-web', version: '3.0.2.RELEASE'
checkstyle 'com.puppycrawl.tools:checkstyle:10.9.3'
checkstyle 'com.github.sevntu-checkstyle:sevntu-checks:1.44.1'
}

dependencies {
Expand All @@ -52,9 +79,207 @@ dependencies {
implementation 'io.swagger.codegen.v3:swagger-codegen-maven-plugin:3.0.16'
}

configure(this) {
// NOTE: order matters!
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'net.ltgt.errorprone'
configurations {
implementation.setCanBeResolved(true)
api.setCanBeResolved(true)
}
tasks.withType(JavaCompile) {
options.compilerArgs += [
"-Xlint:unchecked",
"-Xlint:cast",
"-Xlint:auxiliaryclass",
"-Xlint:deprecation",
"-Xlint:dep-ann",
"-Xlint:divzero",
"-Xlint:empty",
"-Xlint:exports",
"-Xlint:fallthrough",
"-Xlint:finally",
"-Xlint:module",
"-Xlint:opens",
"-Xlint:options",
"-Xlint:overloads",
"-Xlint:overrides",
"-Xlint:path",
"-Xlint:processing",
"-Xlint:removal",
"-Xlint:requires-automatic",
"-Xlint:requires-transitive-automatic",
"-Xlint:try",
"-Xlint:varargs",
"-Xlint:preview",
"-Xlint:static",
// -Werror needs to be disabled because EclipseLink's static weaving doesn't generate warning-free code
// and during an IntelliJ recompilation, it fails
//"-Werror",
"-Xmaxwarns",
1500,
"-Xmaxerrs",
1500
]
options.deprecation = true
}
// Configuration for the spotless plugin
// https://github.com/diffplug/spotless/tree/main/plugin-gradle
spotless {
java {
targetExclude '**/build/**', '**/bin/**', '**/out/**'
importOrder() //sort imports alphabetically
removeUnusedImports()
eclipse().configFile "$rootDir/config/ams-formatter.xml"
endWithNewline()
trimTrailingWhitespace()
// Enforce style modifier order
custom 'Modifier ordering', {
def modifierRanking = [
public : 1,
protected : 2,
private : 3,
abstract : 4,
default : 5,
static : 6,
final : 7,
transient : 8,
volatile : 9,
synchronized: 10,
native : 11,
strictfp : 12]
// Find any instance of multiple modifiers. Lead with a non-word character to avoid
// accidental matching against for instance, "an alternative default value"
it.replaceAll(/\W(?:public |protected |private |abstract |default |static |final |transient |volatile |synchronized |native |strictfp ){2,}/, {
// Do not replace the leading non-word character. Identify the modifiers
it.replaceAll(/(?:public |protected |private |abstract |default |static |final |transient |volatile |synchronized |native |strictfp ){2,}/, {
// Sort the modifiers according to the ranking above
it.split().sort({ modifierRanking[it] }).join(' ') + ' '
}
)
}
)
}
}
lineEndings 'UNIX'
}
// If we are running Gradle within Eclipse to enhance classes,
// set the classes directory to point to Eclipse's default build directory
if (project.hasProperty('env') && project.getProperty('env') == 'eclipse') {
sourceSets.main.java.outputDir = file("$projectDir/bin/main")
}
// Configuration for the Checkstyle plugin
// https://docs.gradle.org/current/userguide/checkstyle_plugin.html
dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:10.3.1'
checkstyle 'com.github.sevntu-checkstyle:sevntu-checks:1.42.0'
}
// Configuration for the errorprone plugin
// https://github.com/tbroyer/gradle-errorprone-plugin
dependencies {
errorprone "com.google.errorprone:error_prone_core:2.20.0"
}

tasks.withType(JavaCompile) {
options.errorprone {
enabled = project.gradle.startParameter.taskNames.contains('build') || project.gradle.startParameter.taskNames.contains('check')
disableWarningsInGeneratedCode = true
excludedPaths = ".*/build/.*"
disable(
// TODO Remove disabled checks from this list, by fixing remaining usages
"UnusedVariable",
"TypeParameterUnusedInFormals",
"EmptyBlockTag",
"MissingSummary",
"InvalidParam",
"ReturnFromVoid",
"AlmostJavadoc",
"InvalidBlockTag",
"JavaUtilDate", // TODO FINERACT-1298
"ReturnValueIgnored",
"DirectInvocationOnMock",
"CanIgnoreReturnValueSuggester",
"SameNameButDifferent", // Until errorprone recognizes Lombok
"MultiVariableDeclaration", // Until errorprone recognizes Lombok
"UnnecessaryDefaultInEnumSwitch" // FINERACT-1911
)
error(
"DefaultCharset",
"RemoveUnusedImports",
"WaitNotInLoop",
"ThreeLetterTimeZoneID",
"VariableNameSameAsType",
"UnnecessaryParentheses",
"MultipleTopLevelClasses",
"MixedMutabilityReturnType",
"AssertEqualsArgumentOrderChecker",
"EmptySetMultibindingContributions",
"BigDecimalEquals",
"MixedArrayDimensions",
"PackageLocation",
"UseBinds",
"BadImport",
"IntLongMath",
"FloatCast",
"ReachabilityFenceUsage",
"StreamResourceLeak",
"TruthIncompatibleType",
"ByteBufferBackingArray",
"OrphanedFormatString",
"CatchAndPrintStackTrace",
"ObjectToString",
"StringSplitter",
"AssertThrowsMultipleStatements",
"BoxedPrimitiveConstructor",
"EmptyCatch",
"BoxedPrimitiveEquality",
"SynchronizeOnNonFinalField",
"WildcardImport",
"PrivateConstructorForNoninstantiableModule",
"ClassCanBeStatic",
"ClassNewInstance",
"UnnecessaryStaticImport",
"UnsafeFinalization",
"JavaTimeDefaultTimeZone",
"JodaPlusMinusLong",
"SwitchDefault",
"VarTypeName",
"ArgumentSelectionDefectChecker",
"CompareToZero",
"InjectOnConstructorOfAbstractClass",
"ImmutableEnumChecker",
"NarrowingCompoundAssignment",
"MissingCasesInEnumSwitch",
"ReferenceEquality",
"UnescapedEntity",
"ModifyCollectionInEnhancedForLoop",
"NonCanonicalType",
"InvalidInlineTag",
"MutablePublicArray",
"StaticAssignmentInConstructor",
"ProtectedMembersInFinalClass",
"OperatorPrecedence",
"EqualsUnsafeCast",
"DoubleBraceInitialization",
"UnusedNestedClass",
"UnusedMethod",
"ModifiedButNotUsed",
"InconsistentCapitalization",
)
}
}
}
group = 'org.mifos'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = '11'
sourceCompatibility = JavaVersion.VERSION_17

checkstyle {
checkstyleMain.exclude '**/fineractstub/**'
}


publishing {
publications {
Expand Down
Loading

0 comments on commit a27cb1f

Please sign in to comment.