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

upgrades ktlint to version 0.49.0 #53

Merged
merged 1 commit into from
Apr 21, 2023
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

- name: Lint check
uses: musichin/ktlint-check@v2
with:
ktlint-version: 0.47.0
ktlint-version: 0.48.2

- name: Build with Gradle
run: ./gradlew build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ktlint GitHub reporter
[![Kotlin](https://img.shields.io/badge/Kotlin-1.7.22-blue.svg)](http://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/Kotlin-1.8.20-blue.svg)](http://kotlinlang.org)
[![CI](https://github.com/musichin/ktlint-github-reporter/actions/workflows/ci.yml/badge.svg)](https://github.com/musichin/ktlint-github-reporter/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/musichin/ktlint-github-reporter/branch/main/graph/badge.svg?token=I2LXI4OUBT)](https://codecov.io/gh/musichin/ktlint-github-reporter)

Expand Down
14 changes: 4 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.7.22"
kotlin("jvm") version "1.8.20"
jacoco
id("com.vanniktech.maven.publish") version "0.22.0"
id("com.vanniktech.maven.publish") version "0.25.2"
}

repositories {
mavenCentral()
}

dependencies {
implementation("com.pinterest.ktlint:ktlint-core:0.48.0")
implementation("com.pinterest.ktlint:ktlint-cli-reporter:0.49.0")
testImplementation(kotlin("test"))
}

tasks.test {
useJUnit()
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

jacoco {
toolVersion = "0.8.8"
toolVersion = "0.8.9"
}

tasks.jacocoTestReport {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 12 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package de.musichin.ktlint.reporter.github

import com.pinterest.ktlint.core.LintError
import com.pinterest.ktlint.core.Reporter
import com.pinterest.ktlint.cli.reporter.core.api.KtlintCliError
import com.pinterest.ktlint.cli.reporter.core.api.KtlintCliError.Status.FORMAT_IS_AUTOCORRECTED
import com.pinterest.ktlint.cli.reporter.core.api.ReporterV2
import java.io.PrintStream

class GitHubReporter(
private val out: PrintStream,
val level: Level = Level.ERROR,
) : Reporter {
) : ReporterV2 {

override fun onLintError(file: String, err: LintError, corrected: Boolean) {
if (corrected) return
override fun onLintError(file: String, ktlintCliError: KtlintCliError) {
if (level == Level.NONE) return
if (ktlintCliError.status == FORMAT_IS_AUTOCORRECTED) return

val line = err.line
val column = err.col
val message = escape(err.detail)
val line = ktlintCliError.line
val column = ktlintCliError.col
val message = escape(ktlintCliError.detail)
val command = level.name.lowercase()
out.println("::$command file=$file,line=$line,col=$column::$message")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.musichin.ktlint.reporter.github

import com.pinterest.ktlint.core.ReporterProvider
import com.pinterest.ktlint.cli.reporter.core.api.ReporterProviderV2
import java.io.PrintStream

class GitHubReporterProvider : ReporterProvider<GitHubReporter> {
class GitHubReporterProvider : ReporterProviderV2<GitHubReporter> {
override val id: String = "github"

override fun get(out: PrintStream, opt: Map<String, String>): GitHubReporter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.musichin.ktlint.reporter.github

import com.pinterest.ktlint.core.LintError
import com.pinterest.ktlint.cli.reporter.core.api.KtlintCliError
import com.pinterest.ktlint.cli.reporter.core.api.KtlintCliError.Status.FORMAT_IS_AUTOCORRECTED
import com.pinterest.ktlint.cli.reporter.core.api.KtlintCliError.Status.LINT_CAN_NOT_BE_AUTOCORRECTED
import org.junit.Test
import java.io.ByteArrayOutputStream
import java.io.PrintStream
Expand All @@ -14,9 +16,9 @@ class GitHubReporterTest {
val out = PrintStream(stream)
val reporter = GitHubReporter(out, Level.ERROR)

val lintError = LintError(1, 2, "testRuleId", "testDetail")
val lintError = KtlintCliError(1, 2, "testRuleId", "testDetail", LINT_CAN_NOT_BE_AUTOCORRECTED)
reporter.before("testFile")
reporter.onLintError("testFile", lintError, false)
reporter.onLintError("testFile", lintError)
reporter.after("testFile")

val result = stream.toString().trim()
Expand All @@ -29,9 +31,9 @@ class GitHubReporterTest {
val out = PrintStream(stream)
val reporter = GitHubReporter(out, Level.WARNING)

val lintError = LintError(1, 2, "testRuleId", "testDetail")
val lintError = KtlintCliError(1, 2, "testRuleId", "testDetail", LINT_CAN_NOT_BE_AUTOCORRECTED)
reporter.before("testFile")
reporter.onLintError("testFile", lintError, false)
reporter.onLintError("testFile", lintError)
reporter.after("testFile")

val result = stream.toString().trim()
Expand All @@ -44,9 +46,9 @@ class GitHubReporterTest {
val out = PrintStream(stream)
val reporter = GitHubReporter(out, Level.NOTICE)

val lintError = LintError(1, 2, "testRuleId", "testDetail")
val lintError = KtlintCliError(1, 2, "testRuleId", "testDetail", LINT_CAN_NOT_BE_AUTOCORRECTED)
reporter.before("testFile")
reporter.onLintError("testFile", lintError, false)
reporter.onLintError("testFile", lintError)
reporter.after("testFile")

val result = stream.toString().trim()
Expand All @@ -59,9 +61,9 @@ class GitHubReporterTest {
val out = PrintStream(stream)
val reporter = GitHubReporter(out, Level.NONE)

val lintError = LintError(1, 2, "testRuleId", "testDetail")
val lintError = KtlintCliError(1, 2, "testRuleId", "testDetail", LINT_CAN_NOT_BE_AUTOCORRECTED)
reporter.before("testFile")
reporter.onLintError("testFile", lintError, false)
reporter.onLintError("testFile", lintError)
reporter.after("testFile")

val result = stream.toString().trim()
Expand All @@ -74,9 +76,9 @@ class GitHubReporterTest {
val out = PrintStream(stream)
val reporter = GitHubReporter(out, Level.ERROR)

val lintError = LintError(1, 2, "testRuleId", "testDetail")
val lintError = KtlintCliError(1, 2, "testRuleId", "testDetail", FORMAT_IS_AUTOCORRECTED)
reporter.before("testFile")
reporter.onLintError("testFile", lintError, true)
reporter.onLintError("testFile", lintError)
reporter.after("testFile")

val result = stream.toString().trim()
Expand Down