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

Improve text location: MatchingDeclarationName #2062

Merged
merged 4 commits into from
Nov 2, 2019
Merged

Improve text location: MatchingDeclarationName #2062

merged 4 commits into from
Nov 2, 2019

Conversation

BraisGabin
Copy link
Member

@BraisGabin BraisGabin commented Oct 27, 2019

No description provided.

@@ -97,6 +104,14 @@ internal class MatchingDeclarationNameSpec : Spek({
assertThat(findings).hasLocationStrings("'object O' at (1,1) in /Objects.kt")
}

it("should not pass for object declaration even with suppress on the object") {
val ktFile = compileContentForTest("""@Suppress("MatchingDeclarationName") object O""")
ktFile.name = "Objects.kt"
Copy link
Member

@arturbosch arturbosch Oct 28, 2019

Choose a reason for hiding this comment

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

We could give the compileContentForTest function or even the (compileAnd)Lint functions a second parameter filename so we can skip setting up the name for the KtFile here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just did a little research... Why do we use the functions inside CompileExtensions.kt? They provide nothing... And why the file is called extensions if they are not extension functions?

I did a fast fix for this PR but I can create (later) a new PR removing that file and using KtTestCompiler directly. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

True the naming is kinda odd.
The intention was to not use the KtTestCompiler directly. compileContentForTest is more concise for tests.

@arturbosch arturbosch added this to the 1.2.0 milestone Oct 28, 2019
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@2717a52). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2062   +/-   ##
=========================================
  Coverage          ?   80.36%           
  Complexity        ?     2015           
=========================================
  Files             ?      332           
  Lines             ?     5662           
  Branches          ?     1044           
=========================================
  Hits              ?     4550           
  Misses            ?      559           
  Partials          ?      553
Impacted Files Coverage Δ Complexity Δ
...sch/detekt/rules/naming/MatchingDeclarationName.kt 93.33% <100%> (ø) 7 <0> (?)

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 2717a52...ea8cf75. Read the comment docs.

@arturbosch arturbosch merged commit 07976a5 into detekt:master Nov 2, 2019
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
* Use trimIndent() in MatchingDeclarationNameSpec

* Add test to ensure that @Suppress works in MatchingDeclarationName

* Improve TextLocation for MatchingDeclarationName

* Allow to pass the Filename directly to compileContentForTest
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
* Use trimIndent() in MatchingDeclarationNameSpec

* Add test to ensure that @Suppress works in MatchingDeclarationName

* Improve TextLocation for MatchingDeclarationName

* Allow to pass the Filename directly to compileContentForTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants