Skip to content
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

Adding diktat analyzer #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import com.saveourtool.diktat.plugin.gradle.DiktatExtension
import com.saveourtool.diktat.plugin.gradle.DiktatGradlePlugin

plugins {
id("com.saveourtool.template.build.kafka-local-run-configuration")
id("com.saveourtool.diktat") version "2.0.0" apply false
}

group = "com.saveourtool.template"
group = "com.saveourtool.template"

allprojects {
repositories {
mavenLocal()
mavenCentral()
}
apply<DiktatGradlePlugin>()
configure<DiktatExtension> {
diktatConfigFile = rootProject.file("diktat-analysis.yml")
inputs {
include("src/**/*.kt")
exclude("src/")
}
debug = true
}
}
135 changes: 135 additions & 0 deletions diktat-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# https://github.com/saveourtool/diktat
- name: DIKTAT_COMMON
enabled: true
configuration:
domainName: com.saveourtool
kotlinVersion: 1.9
srcDirectories: "main,commonMain,jvmMain"
testDirs: "test,jvmTest,commonTest"
- name: ENUM_VALUE
enabled: true
configuration:
enumStyle: SNAKE_CASE
- name: KDOC_CONTAINS_DATE_OR_AUTHOR
enabled: true
configuration:
versionRegex: \d+\.\d+\.\d+[-.\w\d]*
- name: HEADER_MISSING_OR_WRONG_COPYRIGHT
enabled: true
configuration:
isCopyrightMandatory: false
copyrightText: ''
- name: FILE_IS_TOO_LONG
enabled: true
configuration:
maxSize: 2000
ignoreFolders: ''
- name: FILE_UNORDERED_IMPORTS
enabled: true
configuration:
useRecommendedImportsOrder: true
- name: FILE_WILDCARD_IMPORTS
enabled: false
configuration:
allowedWildcards: "kotlinx.serialization.*"
- name: BRACES_BLOCK_STRUCTURE_ERROR
enabled: true
configuration:
openBraceNewline: true
closeBraceNewline: true
- name: WRONG_INDENTATION
enabled: true
configuration:
# Is newline at the end of a file needed
newlineAtEnd: true
# If true: in parameter list when parameters are split by newline they are indented with two indentations instead of one
extendedIndentOfParameters: false
# If true: if first parameter in parameter list is on the same line as opening parenthesis, then other parameters can be aligned with it
alignedParameters: true
# If true: if expression is split by newline after operator like +/-/`*`, then the next line is indented with two indentations instead of one
extendedIndentAfterOperators: true
# If true: when dot qualified expression starts on a new line, this line will be indented with two indentations instead of one
extendedIndentBeforeDot: false
# The indentation size for each file
indentationSize: 4
extendedIndentForExpressionBodies: true
- name: EMPTY_BLOCK_STRUCTURE_ERROR
enabled: true
configuration:
styleEmptyBlockWithNewline: true
allowEmptyBlocks: false
- name: LONG_LINE
enabled: true
configuration:
lineLength: 180
- name: WRONG_NEWLINES
enabled: true
configuration:
maxParametersInOneLine: 3
- name: TOO_MANY_CONSECUTIVE_SPACES
enabled: true
configuration:
maxSpaces: 1
saveInitialFormattingForEnums: false
- name: LONG_NUMERICAL_VALUES_SEPARATED
enabled: true
configuration:
maxNumberLength: 5
maxBlockLength: 3
- name: WRONG_DECLARATIONS_ORDER
enabled: true
configuration:
sortEnum: true
sortProperty: true
- name: COMMENT_WHITE_SPACE
enabled: true
configuration:
maxSpacesBeforeComment: 2
maxSpacesInComment: 1
- name: TYPE_ALIAS
enabled: true
configuration:
typeReferenceLength: 25
- name: TOO_LONG_FUNCTION
enabled: true
configuration:
maxFunctionLength: 55 # max length of function
isIncludeHeader: false # count function's header
- name: TOO_MANY_PARAMETERS
enabled: true
configuration:
maxParameterListSize: 5
- name: NESTED_BLOCK
enabled: true
configuration:
maxNestedBlockQuantity: 4
- name: TRAILING_COMMA
enabled: false
configuration:
valueArgument: true
valueParameter: true
- name: USE_DATA_CLASS
ignoreAnnotated:
- Entity
- name: MISSING_KDOC_CLASS_ELEMENTS
ignoreAnnotated:
- Operation
- Parameters
- Parameter
- JsName
- name: MISSING_KDOC_ON_FUNCTION
ignoreAnnotated:
- Operation
- Parameters
- Parameter
- name: WRONG_OVERLOADING_FUNCTION_ARGUMENTS
ignoreAnnotated:
- GetMapping
- PostMapping
- Repository
- name: KDOC_NO_CONSTRUCTOR_PROPERTY
enabled: true
configuration:
isParamTagsForParameters: false
isParamTagsForPrivateProperties: false
isParamTagsForGenericTypes: false