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

Detect filename is not compliant with PascalCase convention #1117

Merged
merged 14 commits into from
May 31, 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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ An AssertJ style API for testing KtLint rules ([#1444](https://github.com/pinter
- Update Kotlin development version to `1.7.0-RC` and Kotlin version to `1.6.21`.
- Update shadow plugin to `7.1.2` release
- Update picocli to `4.6.3` release

- Simplified rule `filename`. Only when the file contains a single class (including data class, enum class and sealed class) or a single interface, the file name should be identical to that class/interface. In all other cases the file name should be a descriptive name compliant with the PascalCase convention ([#1004](https://github.com/pinterest/ktlint/pull/1117))

### Removed

## [0.45.2] - 2022-04-06
Expand Down Expand Up @@ -91,7 +92,6 @@ This section is applicable when providing rules that depend on one or more value

### Changed
- Print the rule id always in the PlainReporter ([#1121](https://github.com/pinterest/ktlint/issues/1121))
- All wrapping logic is moved from the `indent` rule to the new rule `wrapping` (as part of the `standard` ruleset). In case you currently have disabled the `indent` rule, you may want to reconsider whether this is still necessary or that you also want to disable the new `wrapping` rule to keep the status quo. Both rules can be run independent of each other. ([#835](https://github.com/pinterest/ktlint/issues/835))

## [0.44.0] - 2022-02-15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import com.pinterest.ktlint.core.internal.EditorConfigLoader.Companion.convertTo
import com.pinterest.ktlint.core.internal.KotlinPsiFileFactoryProvider
import com.pinterest.ktlint.core.internal.LineAndColumn
import com.pinterest.ktlint.core.internal.SuppressionLocator
import com.pinterest.ktlint.core.internal.SuppressionLocatorBuilder
import com.pinterest.ktlint.core.internal.VisitorProvider
import com.pinterest.ktlint.core.internal.buildPositionInTextLocator
import com.pinterest.ktlint.core.internal.buildSuppressedRegionsLocator
import com.pinterest.ktlint.core.internal.noSuppression
import java.nio.file.FileSystems
import java.nio.file.Path
import java.nio.file.Paths
Expand Down Expand Up @@ -207,7 +206,7 @@ public object KtLint {

injectUserData(rootNode, editorConfigProperties, mergedUserData)

val suppressedRegionLocator = buildSuppressedRegionsLocator(rootNode)
val suppressedRegionLocator = SuppressionLocatorBuilder.buildSuppressedRegionsLocator(rootNode)

return PreparedCode(
rootNode,
Expand Down Expand Up @@ -290,8 +289,8 @@ public object KtLint {
tripped = true
if (canBeAutoCorrected) {
mutated = true
if (preparedCode.suppressedRegionLocator !== noSuppression) {
preparedCode.suppressedRegionLocator = buildSuppressedRegionsLocator(
if (preparedCode.suppressedRegionLocator !== SuppressionLocatorBuilder.noSuppression) {
preparedCode.suppressedRegionLocator = SuppressionLocatorBuilder.buildSuppressedRegionsLocator(
preparedCode.rootNode
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import java.util.jar.Manifest
* (note that version reported by the fallback might not be null if META-INF/MANIFEST.MF is
* loaded from another JAR on the classpath (e.g. if META-INF/MANIFEST.MF wasn't created as part of the build))
*/
public fun <T> getKtlintVersion(javaClass: Class<T>): String? = javaClass.`package`.implementationVersion
?: javaClass.getResourceAsStream("/META-INF/MANIFEST.MF")?.run {
Manifest(this).mainAttributes.getValue("Implementation-Version")
}
public fun <T> ktlintVersion(javaClass: Class<T>): String? =
javaClass.`package`.implementationVersion ?: getManifestVersion(javaClass)

private fun <T> getManifestVersion(javaClass: Class<T>) =
javaClass.getResourceAsStream("/META-INF/MANIFEST.MF")
?.run {
Manifest(this).mainAttributes.getValue("Implementation-Version")
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ import org.xml.sax.SAXException

private val logger = KotlinLogging.logger {}.initKtLintKLogger()

// TODO: Rename to baseline once the class and methods in this file are no longer in the public API
@Deprecated("Method will be removed from the public API in KtLint 0.47.0 or later. Please create an issue if you have a valid reason for using it.")
public class CurrentBaseline(
public val baselineRules: Map<String, List<LintError>>?,
public val baselineGenerationNeeded: Boolean
)

/**
* Loads the baseline file if one is provided.
*
* @param baselineFilePath the path to the xml baseline file
* @return a [CurrentBaseline] with the file details
*/
@Deprecated("Method will be removed from the public API in KtLint 0.47.0 or later. Please create an issue if you have a valid reason for using it.")
public fun loadBaseline(
baselineFilePath: String
): CurrentBaseline {
Expand Down Expand Up @@ -98,16 +106,12 @@ private fun parseBaselineErrorsByFile(element: Element): MutableList<LintError>
return errors
}

public class CurrentBaseline(
public val baselineRules: Map<String, List<LintError>>?,
public val baselineGenerationNeeded: Boolean
)

/**
* Checks if the list contains the lint error. We cannot use the contains function
* as the `checkstyle` reporter formats the details string and hence the comparison
* normally fails
*/
@Deprecated("Method will be removed from the public API in KtLint 0.47.0 or later. Please create an issue if you have a valid reason for using it.")
public fun List<LintError>.containsLintError(error: LintError): Boolean {
return firstOrNull { lintError ->
lintError.col == error.col &&
Expand All @@ -120,6 +124,7 @@ public fun List<LintError>.containsLintError(error: LintError): Boolean {
* Gets the relative route of the file for baselines
* Also adjusts the slashes for uniformity between file systems
*/
@Deprecated("Method will be removed from the public API in KtLint 0.47.0 or later. Please create an issue if you have a valid reason for using it.")
public val File.relativeRoute: String
get() {
val rootPath = Paths.get("").toAbsolutePath()
Expand Down

This file was deleted.

Loading