Skip to content

Introduce parser and psi module #2716

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

Merged
merged 3 commits into from
May 22, 2020
Merged

Conversation

arturbosch
Copy link
Member

@arturbosch arturbosch commented May 21, 2020

First steps towards cleaner api module and a common core module for Gradle/Sonar/IntelliJ/Compiler-Plugins and Cli module - #2680.

This PR gets rid of our usage of the kotlin compiler internal stuff from our api module.
The api module only references Psi classes inherited inside the Rule/DetektVisitor class.

Nice to have: my hope by introducing simpler modules is to get rid of all the build dependencies for detekt-test which all modules uses as a test implementation dependency. This slows down our build because all parallel threads have to wait until detekt-test is build to start testing.

@codecov
Copy link

codecov bot commented May 21, 2020

Codecov Report

Merging #2716 into master will decrease coverage by 0.00%.
The diff coverage is 60.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2716      +/-   ##
============================================
- Coverage     80.55%   80.54%   -0.01%     
- Complexity     2317     2322       +5     
============================================
  Files           378      380       +2     
  Lines          6928     6940      +12     
  Branches       1255     1256       +1     
============================================
+ Hits           5581     5590       +9     
- Misses          721      723       +2     
- Partials        626      627       +1     
Impacted Files Coverage Δ Complexity Δ
.../kotlin/io/gitlab/arturbosch/detekt/api/RuleSet.kt 27.27% <0.00%> (ø) 1.00 <0.00> (ø)
...lab/arturbosch/detekt/api/internal/PathMatchers.kt 60.00% <ø> (+4.44%) 0.00 <0.00> (ø)
...in/kotlin/io/gitlab/arturbosch/detekt/core/Junk.kt 45.45% <ø> (-4.55%) 0.00 <0.00> (ø)
...lin/io/gitlab/arturbosch/detekt/core/KtCompiler.kt 96.00% <ø> (-0.16%) 8.00 <0.00> (-1.00)
...io/gitlab/arturbosch/detekt/core/KtFileModifier.kt 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...itlab/arturbosch/detekt/core/ProcessingSettings.kt 80.55% <ø> (ø) 17.00 <0.00> (ø)
...n/kotlin/io/github/detekt/parser/DetektPomModel.kt 70.58% <ø> (ø) 5.00 <0.00> (?)
.../io/github/detekt/parser/KotlinEnvironmentUtils.kt 84.90% <ø> (ø) 0.00 <0.00> (?)
...ls/src/main/kotlin/io/github/detekt/psi/KtFiles.kt 33.33% <33.33%> (ø) 0.00 <0.00> (?)
...ain/kotlin/io/gitlab/arturbosch/detekt/api/Rule.kt 93.33% <100.00%> (ø) 13.00 <3.00> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd77ea8...04bde63. Read the comment docs.

import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPackageDirective
import java.nio.file.Paths

/**

Choose a reason for hiding this comment

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

  • ⚠️ The class InvalidPackageDeclaration is using inheritance, consider using composition instead. Does InvalidPackageDeclaration want to expose the complete interface (report, report, visitCondition) of Rule such that InvalidPackageDeclaration can be used where Rule is expected? Indicates inheritance. Does InvalidPackageDeclaration want only some/part of the behavior exposed by Rule? Indicates Composition.

@github-actions
Copy link

Warnings
⚠️

detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/Rule.kt#L10 - The class Rule is using inheritance, consider using composition instead. Does Rule want to expose the complete interface (visitCondition, visit, visitFile) of BaseRule such that Rule can be used where BaseRule is expected? Indicates inheritance. Does Rule want only some/part of the behavior exposed by BaseRule? Indicates Composition.

⚠️

detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/FormattingRule.kt#L24 - The class FormattingRule is using inheritance, consider using composition instead. Does FormattingRule want to expose the complete interface (report, report, visitCondition) of Rule such that FormattingRule can be used where Rule is expected? Indicates inheritance. Does FormattingRule want only some/part of the behavior exposed by Rule? Indicates Composition.

⚠️

detekt-rules/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/InclusionExclusionPatternsSpec.kt#L106 - The class OnlyLibraryTrackingRule is using inheritance, consider using composition instead. Does OnlyLibraryTrackingRule want to expose the complete interface (report, report, visitCondition) of Rule such that OnlyLibraryTrackingRule can be used where Rule is expected? Indicates inheritance. Does OnlyLibraryTrackingRule want only some/part of the behavior exposed by Rule? Indicates Composition.

⚠️

detekt-rules/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/InclusionExclusionPatternsSpec.kt#L129 - The class DummyRule is using inheritance, consider using composition instead. Does DummyRule want to expose the complete interface (report, report, visitCondition) of Rule such that DummyRule can be used where Rule is expected? Indicates inheritance. Does DummyRule want only some/part of the behavior exposed by Rule? Indicates Composition.

Generated by 🚫 Danger Kotlin against 04bde63

@@ -1,12 +1,11 @@
package io.gitlab.arturbosch.detekt.api

import io.github.detekt.psi.absolutePath
Copy link
Member

Choose a reason for hiding this comment

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

Should we keep this in a internal package?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it will get hidden behind a implementation configuration later. I will keep this in mind.

@@ -0,0 +1,11 @@
dependencies {
api(kotlin("compiler-embeddable"))
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this be implementation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately not yet. I will see if this can be done in further PRs.

@arturbosch arturbosch merged commit bff3d64 into master May 22, 2020
@arturbosch arturbosch deleted the introduce-parser-and-psi-module branch May 22, 2020 19:57
@arturbosch arturbosch added this to the 1.10.0 milestone May 22, 2020
@arturbosch arturbosch added the housekeeping Marker for housekeeping tasks and refactorings label Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Marker for housekeeping tasks and refactorings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants