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

Add KtLintAssertThat for asserting unit tests in a fluent style #1444

Merged
merged 8 commits into from
Apr 26, 2022
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ This project adheres to [Semantic Versioning](https://semver.org/).

## Unreleased

### API Changes & RuleSet providers

If you are not an API user nor a RuleSet provider, then you can safely skip this section. Otherwise, please read below carefully and upgrade your usage of ktlint. In this and coming releases, we are changing and adapting important parts of our API in order to increase maintainability and flexibility for future changes. Please avoid skipping a releases as that will make it harder to migrate.

#### Testing KtLint rules

An AssertJ style API for testing KtLint rules ([#1444](https://github.com/pinterest/ktlint/issues/1444)) has been added. Usage of this API is encouraged in favor of using the old RuleExtension API. For more information, see [KtLintAssertThat API]( https://github.com/pinterest/ktlint/blob/master/ktlint-test/README.MD)

### Added

### Fixed

### Changed

* Set Kotlin development version to `1.6.21` and Kotlin version to `1.6.21`.

### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.jetbrains.kotlin.psi.KtEnumEntry
public class EnumEntryNameCaseRule : Rule("enum-entry-name-case") {

internal companion object {
const val ERROR_MESSAGE = "Enum entry name should be uppercase underscore-separated names like \"ENUM_ENTRY\" or upper camel-case like \"EnumEntry\""
val regex = Regex("[A-Z]([A-Za-z\\d]*|[A-Z_\\d]*)")
}

Expand All @@ -26,7 +25,7 @@ public class EnumEntryNameCaseRule : Rule("enum-entry-name-case") {
if (!name.matches(regex)) {
emit(
node.startOffset,
ERROR_MESSAGE,
"Enum entry name should be uppercase underscore-separated names like \"ENUM_ENTRY\" or upper camel-case like \"EnumEntry\"",
false
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import com.pinterest.ktlint.core.ast.ElementType.PACKAGE_DIRECTIVE
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.psi.KtPackageDirective

/**
* @see [Kotlin Style Guide](https://kotlinlang.org/docs/reference/coding-conventions.html#naming-rules)
* @see [Android Style Guide](https://android.github.io/kotlin-guides/style.html#package-names)
*/
class PackageNameRule : Rule("package-name") {

override fun visit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ public class TrailingCommaRule :

private val BOOLEAN_VALUES_SET = setOf("true", "false")

// TODO: Rename property to trailingCommaOnDeclarationSite. The word 'allow' is misleading as the comma is
// enforced when the property is enabled and prohibited when disabled.
public val allowTrailingCommaProperty: UsesEditorConfigProperties.EditorConfigProperty<Boolean> =
UsesEditorConfigProperties.EditorConfigProperty(
type = PropertyType.LowerCasingPropertyType(
Expand All @@ -345,6 +347,8 @@ public class TrailingCommaRule :
"should be enforced on the calling side," +
"e.g. argument-list, when-entries, lambda-arguments, indices, etc."

// TODO: Rename property to trailingCommaOnCallSite. The word 'allow' is misleading as the comma is
// // enforced when the property is enabled and prohibited when disabled.
public val allowTrailingCommaOnCallSiteProperty: UsesEditorConfigProperties.EditorConfigProperty<Boolean> =
UsesEditorConfigProperties.EditorConfigProperty(
type = PropertyType.LowerCasingPropertyType(
Expand Down
Loading