diff --git a/.gitignore b/.gitignore index 3bb4dbc..08558de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.DS_Store + # Built application files *.apk *.ap_ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..69c5780 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +branches: + only: + - master +language: android +jdk: oraclejdk8 +dist: trusty +before_cache: + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ +cache: + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ + - $HOME/.android/build-cache +android: + components: + - tools + - platform-tools + - build-tools-29.0.3 + - android-29 + licenses: + - 'android-sdk-preview-license-52d11cd2' + - 'android-sdk-license-.+' + - 'google-gdk-license-.+' +stages: + - name: Building Project + - name: Running Tests + if: branch = master AND type = push +jobs: + include: + - stage: Building Project + script: "./gradlew check" + env: JOB=Build + - script: "./gradlew detekt" + env: JOB=Linter \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 1620323..0b27de6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,6 +37,10 @@ android { testOptions { unitTests.returnDefaultValues = true } + + lintOptions { + abortOnError false + } } dependencies { diff --git a/base/build.gradle b/base/build.gradle index 12c1a6e..75c9e33 100644 --- a/base/build.gradle +++ b/base/build.gradle @@ -22,6 +22,10 @@ android { testOptions { unitTests.returnDefaultValues = true } + + lintOptions { + abortOnError false + } } dependencies { @@ -45,11 +49,11 @@ dependencies { api deps.okhttp_logging_interceptor api deps.timber //Testing - testImplementation deps.testing.junit - testImplementation deps.testing.koin - androidTestImplementation deps.testing.core - androidTestImplementation deps.testing.rules - androidTestImplementation deps.testing.runner - androidTestImplementation deps.testing.ext - androidTestImplementation deps.testing.espresso + api deps.testing.junit + api deps.testing.koin + api deps.testing.core + api deps.testing.rules + api deps.testing.runner + api deps.testing.ext + api deps.testing.espresso } diff --git a/build.gradle b/build.gradle index cf62116..46f5087 100644 --- a/build.gradle +++ b/build.gradle @@ -13,10 +13,29 @@ buildscript { } } +plugins { + id "io.gitlab.arturbosch.detekt" version "1.5.0" +} + allprojects { addRepos(repositories) } +detekt { + version = "1.5.0" + autoCorrect = true + failFast = false + config = files("$rootDir/tools/detekt.yml") + input = files(rootProject.projectDir) + + reports { + html { + enabled = true + destination = file("$rootDir/build/reports/detekt/report.html") + } + } +} + task clean(type: Delete) { delete rootProject.buildDir } diff --git a/docs/pull_request_template.md b/docs/pull_request_template.md new file mode 100644 index 0000000..b5f5833 --- /dev/null +++ b/docs/pull_request_template.md @@ -0,0 +1,3 @@ +### Proposed changes + +### Sources diff --git a/tools/detekt.yml b/tools/detekt.yml new file mode 100644 index 0000000..58e7062 --- /dev/null +++ b/tools/detekt.yml @@ -0,0 +1,440 @@ +build: + maxIssues: 0 + weights: + # complexity: 2 + # LongParameterList: 1 + # style: 1 + # comments: 1 + +processors: + active: true + exclude: + # - 'FunctionCountProcessor' + # - 'PropertyCountProcessor' + # - 'ClassCountProcessor' + # - 'PackageCountProcessor' + # - 'KtFileCountProcessor' + +console-reports: + active: true + exclude: + # - 'ProjectStatisticsReport' + # - 'ComplexityReport' + # - 'NotificationReport' + # - 'FindingsReport' + # - 'BuildFailureReport' + +comments: + excludes: "**/*Test.kt, **/*Spec.kt" + active: true + CommentOverPrivateFunction: + active: true + CommentOverPrivateProperty: + active: true + EndOfSentenceFormat: + active: false + endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!]$) + UndocumentedPublicClass: + active: false + searchInNestedClass: false + searchInInnerClass: false + searchInInnerObject: false + searchInInnerInterface: false + UndocumentedPublicFunction: + active: false + +complexity: + active: true + ComplexCondition: + active: true + threshold: 4 + ComplexInterface: + active: false + threshold: 10 + includeStaticDeclarations: false + ComplexMethod: + active: true + threshold: 10 + ignoreSingleWhenExpression: false + LabeledExpression: + active: false + LargeClass: + active: false + threshold: 150 + LongMethod: + active: true + threshold: 20 + LongParameterList: + active: false + threshold: 6 + ignoreDefaultParameters: false + MethodOverloading: + active: false + threshold: 6 + NestedBlockDepth: + active: true + threshold: 5 + StringLiteralDuplication: + active: false + threshold: 3 + ignoreAnnotation: true + excludeStringsWithLessThan5Characters: true + ignoreStringsRegex: '$^' + TooManyFunctions: + active: false + thresholdInFiles: 11 + thresholdInClasses: 11 + thresholdInInterfaces: 11 + thresholdInObjects: 11 + thresholdInEnums: 11 + ignoreDeprecated: false + ignorePrivate: false + +empty-blocks: + active: true + EmptyCatchBlock: + active: true + allowedExceptionNameRegex: "^(_|(ignore|expected).*)" + EmptyClassBlock: + active: true + EmptyDefaultConstructor: + active: true + EmptyDoWhileBlock: + active: true + EmptyElseBlock: + active: true + EmptyFinallyBlock: + active: true + EmptyForBlock: + active: true + EmptyFunctionBlock: + active: true + ignoreOverridden: false + EmptyIfBlock: + active: true + EmptyInitBlock: + active: true + EmptyKtFile: + active: true + EmptySecondaryConstructor: + active: true + EmptyWhenBlock: + active: true + EmptyWhileBlock: + active: true + +exceptions: + active: true + ExceptionRaisedInUnexpectedLocation: + active: false + methodNames: 'toString,hashCode,equals,finalize' + InstanceOfCheckForException: + active: true + NotImplementedDeclaration: + active: true + PrintStackTrace: + active: true + RethrowCaughtException: + active: true + ReturnFromFinally: + active: true + SwallowedException: + active: false + ThrowingExceptionFromFinally: + active: true + ThrowingExceptionInMain: + active: true + ThrowingExceptionsWithoutMessageOrCause: + active: true + ThrowingNewInstanceOfSameException: + active: true + TooGenericExceptionCaught: + active: true + exceptionNames: + - Throwable + TooGenericExceptionThrown: + active: true + exceptionNames: + - Throwable + +formatting: + active: true + android: false + autoCorrect: false + ChainWrapping: + active: true + autoCorrect: false + CommentSpacing: + active: true + autoCorrect: false + Filename: + active: true + FinalNewline: + active: true + autoCorrect: false + ImportOrdering: + active: false + autoCorrect: false + Indentation: + active: true + autoCorrect: false + indentSize: 4 + continuationIndentSize: 4 + MaximumLineLength: + active: true + maxLineLength: 120 + ModifierOrdering: + active: true + autoCorrect: false + NoBlankLineBeforeRbrace: + active: true + autoCorrect: false + NoConsecutiveBlankLines: + active: true + autoCorrect: false + NoEmptyClassBody: + active: true + autoCorrect: false + NoLineBreakAfterElse: + active: true + autoCorrect: false + NoLineBreakBeforeAssignment: + active: true + autoCorrect: false + NoMultipleSpaces: + active: true + autoCorrect: false + NoSemicolons: + active: true + autoCorrect: false + NoTrailingSpaces: + active: true + autoCorrect: false + NoUnitReturn: + active: true + autoCorrect: false + NoUnusedImports: + active: true + autoCorrect: false + NoWildcardImports: + active: true + autoCorrect: false + ParameterListWrapping: + active: false + autoCorrect: false + indentSize: 4 + SpacingAroundColon: + active: false + autoCorrect: false + SpacingAroundComma: + active: true + autoCorrect: false + SpacingAroundCurly: + active: true + autoCorrect: false + SpacingAroundKeyword: + active: true + autoCorrect: false + SpacingAroundOperators: + active: true + autoCorrect: false + SpacingAroundRangeOperator: + active: true + autoCorrect: false + StringTemplate: + active: true + autoCorrect: false + +naming: + active: true + ClassNaming: + active: true + classPattern: '[A-Z$][a-zA-Z0-9$]*' + EnumNaming: + active: true + enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' + ForbiddenClassName: + active: false + forbiddenName: '' + FunctionMaxLength: + active: false + maximumFunctionNameLength: 30 + FunctionMinLength: + active: false + minimumFunctionNameLength: 3 + FunctionNaming: + active: true + functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$' + excludeClassPattern: '$^' + excludes: "**/*Test.kt, **/*Spec.kt" + MatchingDeclarationName: + active: false + MemberNameEqualsClassName: + active: false + ignoreOverridden: true + ObjectPropertyNaming: + active: true + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + constantPattern: '[A-Za-z][_A-Za-z0-9]*' + PackageNaming: + active: true + packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$' + TopLevelPropertyNaming: + active: false + constantPattern: '[A-Z][_A-Z0-9]*' + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + privatePropertyPattern: '(_)?[A-Za-z][A-Za-z0-9]*' + VariableMaxLength: + active: false + maximumVariableNameLength: 64 + VariableMinLength: + active: false + minimumVariableNameLength: 1 + VariableNaming: + active: true + variablePattern: '[a-z][A-Za-z0-9]*' + privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + +performance: + active: true + ForEachOnRange: + active: true + SpreadOperator: + active: false + UnnecessaryTemporaryInstantiation: + active: true + +potential-bugs: + active: true + DuplicateCaseInWhenExpression: + active: true + EqualsAlwaysReturnsTrueOrFalse: + active: true + EqualsWithHashCodeExist: + active: true + ExplicitGarbageCollectionCall: + active: true + InvalidRange: + active: true + IteratorHasNextCallsNextMethod: + active: false + IteratorNotThrowingNoSuchElementException: + active: false + LateinitUsage: + active: false + excludeAnnotatedProperties: "" + ignoreOnClassesPattern: "" + UnconditionalJumpStatementInLoop: + active: false + UnreachableCode: + active: true + UnsafeCallOnNullableType: + active: false + UnsafeCast: + active: false + UselessPostfixExpression: + active: true + WrongEqualsTypeParameter: + active: true + +style: + active: true + CollapsibleIfStatements: + active: true + DataClassContainsFunctions: + active: false + conversionFunctionPrefix: 'to' + EqualsNullCall: + active: true + ExpressionBodySyntax: + active: true + includeLineWrapping: false + ForbiddenComment: + active: false + values: 'TODO:,FIXME:' + FunctionOnlyReturningConstant: + active: true + ignoreOverridableFunction: true + excludedFunctions: 'describeContents' + LoopWithTooManyJumpStatements: + active: false + maxJumpCount: 1 + MagicNumber: + active: true + ignoreNumbers: '-1,0,1,2' + ignoreHashCodeFunction: false + ignorePropertyDeclaration: false + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true + ignoreAnnotation: false + ignoreNamedArgument: true + ignoreEnums: true + excludes: "**/*Test.kt, **/*Spec.kt" + MandatoryBracesIfStatements: + active: true + MaxLineLength: + active: true + maxLineLength: 120 + excludePackageStatements: false + excludeImportStatements: false + excludeCommentStatements: false + MayBeConst: + active: true + ModifierOrder: + active: true + NestedClassesVisibility: + active: true + NewLineAtEndOfFile: + active: false + NoTabs: + active: false + OptionalAbstractKeyword: + active: true + OptionalUnit: + active: false + OptionalWhenBraces: + active: false + PreferToOverPairSyntax: + active: false + ProtectedMemberInFinalClass: + active: false + RedundantVisibilityModifierRule: + active: true + ReturnCount: + active: false + max: 2 + excludedFunctions: "equals" + SafeCast: + active: true + SerialVersionUIDInSerializableClass: + active: true + SpacingBetweenPackageAndImports: + active: false + ThrowsCount: + active: true + max: 3 + TrailingWhitespace: + active: true + UnnecessaryAbstractClass: + active: false + UnnecessaryInheritance: + active: true + UnnecessaryParentheses: + active: false + UntilInsteadOfRangeTo: + active: false + UnusedImports: + active: true + UnusedPrivateMember: + active: true + UseDataClass: + active: true + excludeAnnotatedClasses: "" + UtilityClassWithPublicConstructor: + active: true + VarCouldBeVal: + active: true + WildcardImport: + active: false + excludeImports: 'java.util.*' diff --git a/versions.gradle b/versions.gradle index 1c984d7..ec55c79 100644 --- a/versions.gradle +++ b/versions.gradle @@ -24,7 +24,7 @@ deps.kotlin = kotlin ext.deps = deps -def addRepos(RepositoryHandler handler) { +static def addRepos(RepositoryHandler handler) { handler.google() handler.jcenter() handler.maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }