Skip to content
Merged
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
8 changes: 2 additions & 6 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

object Versions {
object IntegrationTest {
const val ktlint = "0.43.2"
const val ktlint = "0.45.2"
const val ktlintLink = "https://github.com/pinterest/ktlint/releases/download/$ktlint/ktlint"
const val diktat = "1.0.2"
const val diktat = "1.1.0"
const val diktatLink = "https://github.com/saveourtool/diKTat/releases/download/v$diktat/diktat-$diktat.jar"
const val oldKtlint = "0.39.0"
const val oldKtlintLink = "https://github.com/pinterest/ktlint/releases/download/$oldKtlint/ktlint"
const val oldDiktat = "1.0.0-rc.2"
const val oldDiktatLink = "https://github.com/saveourtool/diKTat/releases/download/v$oldDiktat/diktat-$oldDiktat.jar"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun Project.configureJacoco() {
apply<JacocoPlugin>()

configure<JacocoPluginExtension> {
toolVersion = "0.8.7"
toolVersion = "0.8.8"
}

val kotlin: KotlinMultiplatformExtension = extensions.getByType()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// ;warn:1:1: [FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: Bug1Expected.kt vs D
// ;warn:1:1: [FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: Bug1Expected.kt vs D{{.*}}
package com.saveourtool.save.chapter1

// ;warn:4:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: D (cannot be auto-corrected)
// ;warn:7:7: [CLASS_NAME_INCORRECT] class/enum/interface name should be in PascalCase and should contain only latin (ASCII) letters or numbers: D
// ;warn:7:7: [IDENTIFIER_LENGTH] identifier's length is incorrect, it should be in range of [2, 64] symbols: D (cannot be auto-corrected)
// ;warn:4:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: D (cannot be auto-corrected){{.*}}
// ;warn:7:7: [CLASS_NAME_INCORRECT] class/enum/interface name should be in PascalCase and should contain only latin (ASCII) letters or numbers: D{{.*}}
// ;warn:7:7: [IDENTIFIER_LENGTH] identifier's length is incorrect, it should be in range of [2, 64] symbols: D (cannot be auto-corrected){{.*}}
class D {
// ;warn:8:5: [MISSING_KDOC_CLASS_ELEMENTS] all public, internal and protected classes, functions and variables inside the class should have Kdoc: x (cannot be auto-corrected)
// ;warn:8:5: [MISSING_KDOC_CLASS_ELEMENTS] all public, internal and protected classes, functions and variables inside the class should have Kdoc: x (cannot be auto-corrected){{.*}}
val x = 0
// ;warn:13:8: [KDOC_NO_EMPTY_TAGS] no empty descriptions in tag blocks are allowed: @return (cannot be auto-corrected)
// ;warn:13:8: [KDOC_NO_EMPTY_TAGS] no empty descriptions in tag blocks are allowed: @return (cannot be auto-corrected){{.*}}

/**
* @return
*/
fun bar(): Bar {
// ;warn:17:19: [MAGIC_NUMBER] avoid using magic numbers, instead define constants with clear names describing what the magic number means: 42 (cannot be auto-corrected)
// ;warn:17:19: [MAGIC_NUMBER] avoid using magic numbers, instead define constants with clear names describing what the magic number means: 42 (cannot be auto-corrected){{.*}}
val qux = 42
return Bar(qux)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ;warn:1:1: [HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE] files that contain multiple or no classes should contain description of what is inside of this file: there are 2 declared classes and/or objects (cannot be auto-corrected)
// ;warn:1:1: [HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE] files that contain multiple or no classes should contain description of what is inside of this file: there are 2 declared classes and/or objects (cannot be auto-corrected){{.*}}
package com.saveourtool.save.chapter2

import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -26,22 +26,17 @@ internal fun createWithFile(
containerName: String,
file: File,
resources: Collection<File> = emptySet()
// ;warn:30:3: [EMPTY_BLOCK_STRUCTURE_ERROR] incorrect format of empty block: empty blocks are forbidden unless it is function with override keyword (cannot be auto-corrected)
// ;warn:30:3: [EMPTY_BLOCK_STRUCTURE_ERROR] incorrect format of empty block: empty blocks are forbidden unless it is function with override keyword (cannot be auto-corrected){{.*}}
) {}

private fun foo(node: ASTNode) {
when (node.elementType) {
CLASS, FUN, PRIMARY_CONSTRUCTOR, SECONDARY_CONSTRUCTOR -> checkAnnotation(node)
else -> {
// this is a generated else block
}
}
val qwe = a &&
// ;warn:41:1: [WRONG_INDENTATION] only spaces are allowed for indentation and each indentation should equal to 4 spaces (tabs are not allowed): expected 12 but was 8
b
b
val qwe = a &&
// ;warn:44:1: [WRONG_INDENTATION] only spaces are allowed for indentation and each indentation should equal to 4 spaces (tabs are not allowed): expected 12 but was 8
b
b

// comment
if (x) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// ;warn:1:1 [FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: Example1Expected.kt vs Example
// ;warn:1:1 [FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: Example1Expected.kt vs Example{{.*}}
package com.saveourtool.save.chapter3

// ;warn:4:1 [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: Example (cannot be auto-corrected)
// ;warn:4:1 [USE_DATA_CLASS] this class can be converted to a data class: Example (cannot be auto-corrected)
// ;warn:4:1 [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: Example (cannot be auto-corrected){{.*}}
// ;warn:4:1 [USE_DATA_CLASS] this class can be converted to a data class: Example (cannot be auto-corrected){{.*}}
class Example {
// ;warn:7:5 [MISSING_KDOC_CLASS_ELEMENTS] all public, internal and protected classes, functions and variables inside the class should have Kdoc: isValid (cannot be auto-corrected)
// ;warn:7:5 [MISSING_KDOC_CLASS_ELEMENTS] all public, internal and protected classes, functions and variables inside the class should have Kdoc: isValid (cannot be auto-corrected){{.*}}
@get:JvmName("getIsValid")
val isValid = true
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.saveourtool.diktat.test.resources.test.paragraph1.naming.enum_

// ;warn:3:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: EnumValueSnakeCaseTest (cannot be auto-corrected)
// ;warn:35: [WRONG_DECLARATIONS_ORDER] declarations of constants and enum members should be sorted alphabetically: enum entries order is incorrect
// ;warn:10:5: [ENUMS_SEPARATED] enum is incorrectly formatted: enums must end with semicolon
// and internal top-level classes and functions should have Kdoc: EnumValueSnakeCaseTest (cannot be auto-corrected){{.*}}
// ;warn:35: [WRONG_DECLARATIONS_ORDER] declarations of constants and enum members should be sorted alphabetically: enum entries order is incorrect{{.*}}
// ;warn:10:5: [ENUMS_SEPARATED] enum is incorrectly formatted: enums must end with semicolon{{.*}}
enum class EnumValueSnakeCaseTest {
// ;warn:$line+1:5: [ENUM_VALUE] enum values should be{{ in }}selected UPPER_CASE snake/PascalCase format: paSC_SAl_l
// ;warn:$line+1:5: [ENUM_VALUE] enum values should be{{ in }}selected UPPER_CASE snake/PascalCase format: paSC_SAl_l{{.*}}
paSC_SAl_l,

// ;warn:5: [ENUM_VALUE] enum values{{ should }}be in selected{{ UPPER_CASE }}snake/PascalCase format: PascAsl_f
// ;warn:5: [ENUM_VALUE] enum values{{ should }}be in selected{{ UPPER_CASE }}snake/PascalCase format: PascAsl_f{{.*}}
PascAsl_f
// ;warn:$line-2:5: [ENUMS_SEPARATED] enum is incorrectly formatted: last enum entry must end with a comma
// ;warn:$line-2:5: [ENUMS_SEPARATED] enum is incorrectly formatted: last enum entry must end with a comma{{.*}}

// ;warn:1:9: {{.*}}[PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: com.saveourtool.save{{.*}}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.saveourtool.diktat.test.resources.test.paragraph1.naming.enum_

// ;warn:3:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: EnumValueSnakeCaseTest (cannot be auto-corrected)
// ;warn:35: [WRONG_DECLARATIONS_ORDER] declarations of constants and enum members should be sorted alphabetically: enum entries order is incorrect
// ;warn:10:5: [ENUMS_SEPARATED] enum is incorrectly formatted: enums must end with semicolon
// ;warn:3:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: EnumValueSnakeCaseTest (cannot be auto-corrected){{.*}}
// ;warn:35: [WRONG_DECLARATIONS_ORDER] declarations of constants and enum members should be sorted alphabetically: enum entries order is incorrect{{.*}}
// ;warn:10:5: [ENUMS_SEPARATED] enum is incorrectly formatted: enums must end with semicolon{{.*}}
enum class EnumValueSnakeCaseTest {
// ;warn:$line+1:5: [ENUM_VALUE] enum values should be{{ in }}selected UPPER_CASE snake/PascalCase format: paSC_SAl_l
// ;warn:$line+1:5: [ENUM_VALUE] enum values should be{{ in }}selected UPPER_CASE snake/PascalCase format: paSC_SAl_l{{.*}}
paSC_SAl_l,

// ;warn:5: [ENUM_VALUE] enum values{{ should }}be in selected{{ UPPER_CASE }}snake/PascalCase format: PascAsl_f
// ;warn:5: [ENUM_VALUE] enum values{{ should }}be in selected{{ UPPER_CASE }}snake/PascalCase format: PascAsl_f{{.*}}
PascAsl_f
// ;warn:$line-2:5: [ENUMS_SEPARATED] enum is incorrectly formatted: last enum entry must end with a comma
// ;warn:$line-2:5: [ENUMS_SEPARATED] enum is incorrectly formatted: last enum entry must end with a comma{{.*}}

// ;warn:1:9: {{.*}}[PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: com.saveourtool.save{{.*}}
}
4 changes: 2 additions & 2 deletions examples/kotlin-diktat/save.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[general]
execCmd = "java -jar ktlint-old --disabled_rules=standard -R diktat-old.jar"
description = "Test for diktat - linter and formatter for Kotlin"
execCmd = "java -jar ktlint --disabled_rules=standard -R diktat.jar"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we release diktat in format diktat-*.jar, maybe change it to java -jar ktlint --disabled_rules=standard -R diktat-*.jar?

description = "22 test for diktat (linter and formatter for Kotlin)"
language = "Kotlin"
# this is the default value, you don't need to add it explicitly, but can be useful, if you have different pattern:
expectedWarningsPattern = "// ;warn:?(.*):(\\d*): (.+)"
Expand Down
20 changes: 10 additions & 10 deletions examples/kotlin-diktat/warn-dir/chapter1/EnumValueSnakeCaseTest.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// ;warn:2:9: [PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: com.saveourtool.save
// ;warn:2:9: [PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: com.saveourtool.save{{.*}}
package com.saveourtool.diktat.test.resources.test.paragraph1.naming.enum_

// ;warn:4:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: EnumValueSnakeCaseTest (cannot be auto-corrected)
// ;warn:8:35: [WRONG_DECLARATIONS_ORDER] declarations of constants and enum members should be sorted alphabetically: enum entries order is incorrect
// ;warn:17:5: [ENUMS_SEPARATED] enum is incorrectly formatted: enums must end with semicolon
// ;warn:17:5: [ENUMS_SEPARATED] enum is incorrectly formatted: last enum entry must end with a comma
// ;warn:4:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: EnumValueSnakeCaseTest (cannot be auto-corrected){{.*}}
Comment thread
nulls marked this conversation as resolved.
// ;warn:8:35: [WRONG_DECLARATIONS_ORDER] declarations of constants and enum members should be sorted alphabetically: enum entries order is incorrect{{.*}}
// ;warn:17:5: [ENUMS_SEPARATED] enum is incorrectly formatted: enums must end with semicolon{{.*}}
// ;warn:17:5: [ENUMS_SEPARATED] enum is incorrectly formatted: last enum entry must end with a comma{{.*}}
enum class EnumValueSnakeCaseTest {
// ;warn:10:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: paSC_SAl_l
// ;warn:10:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: paSC_SAl_l{{.*}}
paSC_SAl_l,
// ;warn:12:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: PascAsl_f
// ;warn:12:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: PascAsl_f{{.*}}
PascAsl_f,
// ;warn:14:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: START_PSaaa_DFE
// ;warn:14:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: START_PSaaa_DFE{{.*}}
START_PSaaa_DFE,
// ;warn:16:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: _NAme_MYa_sayR
// ;warn:16:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: _NAme_MYa_sayR{{.*}}
_NAme_MYa_sayR,
// ;warn:18:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: NAme_MYa_sayR_
// ;warn:18:5: [ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: NAme_MYa_sayR_{{.*}}
NAme_MYa_sayR_
}
14 changes: 7 additions & 7 deletions examples/kotlin-diktat/warn-dir/chapter1/GenericFunctionTest.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// ;warn:3:9: [PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: com.saveourtool.save
// ;warn:1:1: [FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: GenericFunctionTest.kt vs ClassName
// ;warn:3:9: [PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: com.saveourtool.save{{.*}}
// ;warn:1:1: [FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: GenericFunctionTest.kt vs ClassName{{.*}}
package com.saveourtool.diktat.test.paragraph1.naming.generic

private class ClassName<T> {
private fun <Template, T> lock(body: ((Template?) -> T?)?, value: Template?): T? {
try {
// ;warn:10:13: [LOCAL_VARIABLE_EARLY_DECLARATION] local variables should be declared close to the line where they are first used: <variableName> is declared on line <10> and is used for the first time on line <15> (cannot be auto-corrected)
// ;warn:10:43: [NULLABLE_PROPERTY_TYPE] try to avoid use of nullable types: initialize explicitly (cannot be auto-corrected)
// ;warn:10:13: [LOCAL_VARIABLE_EARLY_DECLARATION] local variables should be declared close to the line where they are first used: <variableName> is declared on line <10> and is used for the first time on line <15> (cannot be auto-corrected){{.*}}
// ;warn:10:43: [NULLABLE_PROPERTY_TYPE] try to avoid use of nullable types: initialize explicitly (cannot be auto-corrected){{.*}}
val variableName: Template? = null
// ;warn:13:17: [VARIABLE_NAME_INCORRECT_FORMAT] variable name should be in lowerCamelCase and should contain only latin (ASCII) letters or numbers and should start from lower letter: variableT
// ;warn:13:33: [NULLABLE_PROPERTY_TYPE] try to avoid use of nullable types: initialize explicitly (cannot be auto-corrected)
// ;warn:13:17: [VARIABLE_NAME_INCORRECT_FORMAT] variable name should be in lowerCamelCase and should contain only latin (ASCII) letters or numbers and should start from lower letter: variableT{{.*}}
// ;warn:13:33: [NULLABLE_PROPERTY_TYPE] try to avoid use of nullable types: initialize explicitly (cannot be auto-corrected){{.*}}
val variableT: T? = null
println(variableT)
return body!!(variableName)
Expand All @@ -18,7 +18,7 @@ private class ClassName<T> {
}
}

// ;warn:21:5: [MISSING_KDOC_ON_FUNCTION] all public, internal and protected functions should have Kdoc with proper tags: foo
// ;warn:21:5: [MISSING_KDOC_ON_FUNCTION] all public, internal and protected functions should have Kdoc with proper tags: foo{{.*}}
fun foo(var1: T, var2: ((T?) -> T?)?) {
lock<T, T>(var2, var1)
}
Expand Down
6 changes: 3 additions & 3 deletions examples/kotlin-diktat/warn-dir/chapter1/SmallTest.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ;warn:1:1: [FILE_CONTAINS_ONLY_COMMENTS] empty files or files that contain only comments should be avoided: file contains no code (cannot be auto-corrected)
// ;warn:1:1: [HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE] files that contain multiple or no classes should contain description of what is inside of this file: there are 0 declared classes and/or objects (cannot be auto-corrected)
// ;warn:4:9: [PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: com.saveourtool.save
// ;warn:1:1: [FILE_CONTAINS_ONLY_COMMENTS] empty files or files that contain only comments should be avoided: file contains no code (cannot be auto-corrected){{.*}}
// ;warn:1:1: [HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE] files that contain multiple or no classes should contain description of what is inside of this file: there are 0 declared classes and/or objects (cannot be auto-corrected){{.*}}
// ;warn:4:9: [PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: com.saveourtool.save{{.*}}
package com.saveourtool.diktat.test.paragraph1.naming.generic
Loading