Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into remove-naming-multyrule
Browse files Browse the repository at this point in the history
  • Loading branch information
v.stelmashchuk committed Sep 5, 2022
2 parents 70582b3 + d516562 commit 1871aac
Show file tree
Hide file tree
Showing 357 changed files with 3,933 additions and 7,577 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codecoverage.yaml
Expand Up @@ -29,7 +29,7 @@ jobs:
distribution: 'temurin'

- name: Generate Coverage Report
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: jacocoMergedReport

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/danger.yaml
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3

- name: Setup Node
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-snapshot.yaml
Expand Up @@ -26,12 +26,12 @@ jobs:
distribution: 'temurin'

- name: Build detekt
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: build

- name: Deploy Snapshot
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
env:
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/detekt-with-type-resolution.yaml
Expand Up @@ -34,12 +34,12 @@ jobs:
distribution: 'temurin'

- name: Run detekt-cli with argsfile
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: :detekt-cli:runWithArgsFile

- name: Upload SARIF to Github using the upload-sarif action
uses: github/codeql-action/upload-sarif@2ca79b6fa8d3ec278944088b4aa5f46912db5d63 # tag=v2
uses: github/codeql-action/upload-sarif@b398f525a5587552e573b247ac661067fafa920b # tag=v2
if: ${{ always() }}
with:
sarif_file: build/detekt-report.sarif
Expand All @@ -58,6 +58,6 @@ jobs:
java-version: 17
distribution: 'temurin'
- name: Run analysis
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: detektMain detektTest
14 changes: 7 additions & 7 deletions .github/workflows/pre-merge.yaml
Expand Up @@ -37,7 +37,7 @@ jobs:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
- name: Build detekt
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: build -x detekt
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3
Expand All @@ -46,15 +46,15 @@ jobs:
path: '**.hprof'
if-no-files-found: ignore
- name: Run detekt-cli --help
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: :detekt-cli:runWithHelpFlag
- name: Run detekt-cli with argsfile
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: :detekt-cli:runWithArgsFile
- name: Try to publish to Maven Local
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: publishToMavenLocal

Expand All @@ -70,7 +70,7 @@ jobs:
java-version: 17
distribution: 'temurin'
- name: Verify Generated Detekt Config File
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: verifyGeneratorOutput

Expand All @@ -86,7 +86,7 @@ jobs:
java-version: 17
distribution: 'temurin'
- name: Build and compile test snippets
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: test -Pcompile-test-snippets=true

Expand All @@ -102,6 +102,6 @@ jobs:
java-version: 17
distribution: 'temurin'
- name: Run with allWarningsAsErrors
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: build -x detekt -PwarningsAsErrors=true
2 changes: 1 addition & 1 deletion .github/workflows/website.yaml
Expand Up @@ -36,7 +36,7 @@ jobs:
cache-dependency-path: 'website/yarn.lock'

- name: Build Detekt Documentation
uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2
uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2
with:
arguments: :detekt-generator:generateDocumentation

Expand Down
2 changes: 1 addition & 1 deletion bots/package.json
Expand Up @@ -7,6 +7,6 @@
"main": "index.js",
"license": "MIT",
"devDependencies": {
"danger": "^11.1.1"
"danger": "11.1.2"
}
}
8 changes: 4 additions & 4 deletions bots/yarn.lock
Expand Up @@ -196,10 +196,10 @@ core-js@^3.8.2:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.24.1.tgz#cf7724d41724154010a6576b7b57d94c5d66e64f"
integrity sha512-0QTBSYSUZ6Gq21utGzkfITDylE8jWC9Ne1D2MrhvlsZBI1x39OdDIVbzSqtgMndIy6BlHxBXpMGqzZmnztg2rg==

danger@^11.1.1:
version "11.1.1"
resolved "https://registry.yarnpkg.com/danger/-/danger-11.1.1.tgz#b745f6191c1478dd4ef81596ac96be8f8e2d0634"
integrity sha512-kQX1/Rggut/KFgArOloAdw6paB7hkoznRaUhpPFKVHKRgc6FtlhC8zpb480jVE71Z6eI7rrHVDGEYLv8x96yyA==
danger@11.1.2:
version "11.1.2"
resolved "https://registry.yarnpkg.com/danger/-/danger-11.1.2.tgz#6fa7807c8721e9f8a040252ae8a22db222b8c4e0"
integrity sha512-tlAyADE7BRHbnoAA7BB7RzcO/ZLvXMpnWms7dBT/Tm4ntxdbrTT6wCPO1qFcd5Jc9LfM0Iez3hKUSINtnPLH+g==
dependencies:
"@octokit/rest" "^18.12.0"
async-retry "1.2.3"
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/releasing.gradle.kts
Expand Up @@ -26,7 +26,7 @@ project.afterEvaluate {
draft.set(true)
targetCommitish.set("main")
body {
var changelog = project.file("website/docs/introduction/changelog 1.x.x.md").readText()
var changelog = project.file("website/docs/introduction/changelog.md").readText()
val nextNonBetaVersion = project.version.toString()
val sectionStart = "#### $nextNonBetaVersion"
changelog = changelog.substring(changelog.indexOf(sectionStart))
Expand Down
26 changes: 10 additions & 16 deletions config/detekt/detekt.yml
Expand Up @@ -69,29 +69,21 @@ formatting:
active: true
android: false
autoCorrect: true
AnnotationSpacing:
active: true
EnumEntryNameCase:
active: true
Filename:
active: false
MaximumLineLength:
active: false
MultiLineIfElse:
active: true
NoEmptyFirstLineInMethodBlock:
FunctionReturnTypeSpacing:
active: true
PackageName:
FunctionStartOfBodySpacing:
active: true
SpacingAroundAngleBrackets:
active: true
SpacingAroundDoubleColon:
MaximumLineLength:
active: false
NullableTypeSpacing:
active: true
SpacingAroundUnaryOperator:
ParameterListSpacing:
active: true
SpacingBetweenDeclarationsWithAnnotations:
SpacingBetweenFunctionNameAndOpeningParenthesis:
active: true
SpacingBetweenDeclarationsWithComments:
TypeParameterListSpacing:
active: true

naming:
Expand Down Expand Up @@ -237,6 +229,8 @@ style:
excludeGuardClauses: true
SpacingBetweenPackageAndImports:
active: true
TrimMultilineRawString:
active: true
UnderscoresInNumericLiterals:
active: true
UnnecessaryAnnotationUseSiteTarget:
Expand Down
Expand Up @@ -51,10 +51,7 @@ constructor(

@Suppress("DEPRECATION")
@Deprecated(
"""
locationString was removed and won't get passed to the main constructor.
Use queries on 'ktElement' instead.
""",
"locationString was removed and won't get passed to the main constructor. Use queries on 'ktElement' instead.",
ReplaceWith(
"Location(source, text, file)",
"io.gitlab.arturbosch.detekt.api.Location"
Expand Down
Expand Up @@ -18,7 +18,8 @@ class ElementPrinterSpec {
}
}

private val expected = """0: KtFile
private val expected = """
0: KtFile
1: KtPackageDirective
1: KtNameReferenceExpression
1: KtImportList
Expand Down
Expand Up @@ -11,7 +11,7 @@ class BaselineFacade {

fun transformResult(baselineFile: Path, result: Detektion): Detektion {
return if (baselineExists(baselineFile)) {
BaselineFilteredResult(result, Baseline.load(baselineFile))
BaselineFilteredResult(result, DefaultBaseline.load(baselineFile))
} else {
result
}
Expand All @@ -20,14 +20,15 @@ class BaselineFacade {
fun createOrUpdate(baselineFile: Path, findings: List<Finding>) {
val ids = findings.map { it.baselineId }.toSortedSet()
val oldBaseline = if (baselineExists(baselineFile)) {
Baseline.load(baselineFile)
DefaultBaseline.load(baselineFile)
} else {
Baseline(emptySet(), emptySet())
DefaultBaseline(emptySet(), emptySet())
}
val baseline = oldBaseline.copy(currentIssues = ids)
val baselineFormat = BaselineFormat()
val baseline = baselineFormat.of(oldBaseline.manuallySuppressedIssues, ids)
if (oldBaseline != baseline) {
baselineFile.parent?.let { Files.createDirectories(it) }
BaselineFormat().write(baseline, baselineFile)
baselineFormat.write(baselineFile, baseline)
}
}

Expand Down
@@ -1,12 +1,13 @@
package io.gitlab.arturbosch.detekt.core.baseline

import io.github.detekt.tooling.api.Baseline
import io.gitlab.arturbosch.detekt.api.Detektion
import io.gitlab.arturbosch.detekt.api.Finding
import io.gitlab.arturbosch.detekt.api.RuleSetId

internal class BaselineFilteredResult(
result: Detektion,
private val baseline: Baseline
private val baseline: Baseline,
) : Detektion by result {

override val findings: Map<RuleSetId, List<Finding>> = result.findings
Expand Down
@@ -1,5 +1,10 @@
package io.gitlab.arturbosch.detekt.core.baseline

import io.github.detekt.tooling.api.Baseline
import io.github.detekt.tooling.api.BaselineProvider
import io.github.detekt.tooling.api.FindingId
import io.github.detekt.tooling.api.FindingsIdList
import io.gitlab.arturbosch.detekt.api.Finding
import org.xml.sax.SAXParseException
import java.nio.file.Files
import java.nio.file.Path
Expand All @@ -8,16 +13,21 @@ import javax.xml.parsers.SAXParserFactory
import javax.xml.stream.XMLStreamException
import javax.xml.stream.XMLStreamWriter

internal class BaselineFormat {
internal class BaselineFormat : BaselineProvider {

private val XMLStreamException.positions
get() = location.lineNumber to location.columnNumber

class InvalidState(msg: String, error: Throwable) : IllegalStateException(msg, error)

fun read(path: Path): Baseline {
override fun id(finding: Finding): FindingId = finding.baselineId

override fun of(manuallySuppressedIssues: FindingsIdList, currentIssues: FindingsIdList): DefaultBaseline =
DefaultBaseline(manuallySuppressedIssues, currentIssues)

override fun read(sourcePath: Path): DefaultBaseline {
try {
Files.newInputStream(path).use {
Files.newInputStream(sourcePath).use {
val reader = SAXParserFactory.newInstance()
.apply {
setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true)
Expand All @@ -33,9 +43,9 @@ internal class BaselineFormat {
}
}

fun write(baseline: Baseline, path: Path) {
override fun write(targetPath: Path, baseline: Baseline) {
try {
Files.newBufferedWriter(path).addFinalNewLine().use {
Files.newBufferedWriter(targetPath).addFinalNewLine().use {
it.streamXml().prettyPrinter().save(baseline)
}
} catch (error: XMLStreamException) {
Expand Down
Expand Up @@ -11,7 +11,7 @@ internal class BaselineHandler : DefaultHandler() {
private val currentIssues = mutableSetOf<String>()
private val manuallySuppressedIssues = mutableSetOf<String>()

internal fun createBaseline() = Baseline(manuallySuppressedIssues, currentIssues)
internal fun createBaseline() = DefaultBaseline(manuallySuppressedIssues, currentIssues)

override fun startElement(uri: String, localName: String, qName: String, attributes: Attributes) {
when (qName) {
Expand Down
@@ -1,19 +1,19 @@
package io.gitlab.arturbosch.detekt.core.baseline

import io.github.detekt.tooling.api.Baseline
import io.github.detekt.tooling.api.FindingId
import io.github.detekt.tooling.api.FindingsIdList
import io.gitlab.arturbosch.detekt.api.Finding
import io.gitlab.arturbosch.detekt.core.exists
import io.gitlab.arturbosch.detekt.core.isFile
import java.nio.file.Path

internal typealias FindingsIdList = Set<String>
internal typealias FindingId = String
internal data class DefaultBaseline(
override val manuallySuppressedIssues: FindingsIdList,
override val currentIssues: FindingsIdList,
) : Baseline {

internal data class Baseline(
val manuallySuppressedIssues: FindingsIdList,
val currentIssues: FindingsIdList
) {

fun contains(id: FindingId): Boolean =
override fun contains(id: FindingId): Boolean =
currentIssues.contains(id) || manuallySuppressedIssues.contains(id)

companion object {
Expand Down
@@ -1,6 +1,8 @@
package io.gitlab.arturbosch.detekt.core.config

import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.core.config.validation.ValidatableConfiguration
import io.gitlab.arturbosch.detekt.core.config.validation.validateConfig

@Suppress("UNCHECKED_CAST")
internal data class AllRulesConfig(
Expand Down
Expand Up @@ -2,6 +2,8 @@ package io.gitlab.arturbosch.detekt.core.config

import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.Notification
import io.gitlab.arturbosch.detekt.core.config.validation.ValidatableConfiguration
import io.gitlab.arturbosch.detekt.core.config.validation.validateConfig

/**
* Wraps two different configuration which should be considered when retrieving properties.
Expand Down

0 comments on commit 1871aac

Please sign in to comment.