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

Teststate enhancement #5920

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aydinomer00
Copy link

@aydinomer00 aydinomer00 commented Dec 28, 2024

Description

This PR adds an exception for @TestState usage in the QuickDiscouragedCallRule. The rule now excludes @TestState declarations inside describe and context blocks.

Changes Made

  • Updated QuickDiscouragedCallRule to add an exception for @TestState.
  • Added relevant test cases in QuickDiscouragedCallRuleTests.
  • Updated CHANGELOG.md to include details about this enhancement.

Current Issues

While the implementation and tests were added successfully, the CI/CD pipeline is failing due to issues in:

  1. IntegrationTests
  2. SwiftLintFrameworkTests

I am currently unable to resolve these failing tests and would appreciate any guidance or suggestions to address them.


Thank you for your support and patience as I work through this contribution!

@SwiftLintBot
Copy link

SwiftLintBot commented Dec 28, 2024

17 Messages
📖 Linting Aerial with this PR took 0.97s vs 0.94s on main (3% slower)
📖 Linting Alamofire with this PR took 1.3s vs 1.28s on main (1% slower)
📖 Linting Brave with this PR took 6.69s vs 6.73s on main (0% faster)
📖 Linting DuckDuckGo with this PR took 5.55s vs 5.57s on main (0% faster)
📖 Linting Firefox with this PR took 11.08s vs 11.18s on main (0% faster)
📖 Linting Kickstarter with this PR took 10.45s vs 10.43s on main (0% slower)
📖 Linting Moya with this PR took 0.54s vs 0.53s on main (1% slower)
📖 Linting NetNewsWire with this PR took 2.97s vs 3.03s on main (1% faster)
📖 Linting Nimble with this PR took 0.8s vs 0.8s on main (0% slower)
📖 Linting PocketCasts with this PR took 8.82s vs 8.72s on main (1% slower)
📖 Linting Quick with this PR took 0.45s vs 0.46s on main (2% faster)
📖 Linting Realm with this PR took 4.56s vs 4.56s on main (0% slower)
📖 Linting Sourcery with this PR took 2.34s vs 2.36s on main (0% faster)
📖 Linting Swift with this PR took 4.61s vs 4.59s on main (0% slower)
📖 Linting VLC with this PR took 1.27s vs 1.28s on main (0% faster)
📖 Linting Wire with this PR took 18.72s vs 18.74s on main (0% faster)
📖 Linting WordPress with this PR took 11.66s vs 11.63s on main (0% slower)

Generated by 🚫 Danger

@SimplyDanny SimplyDanny linked an issue Dec 29, 2024 that may be closed by this pull request
2 tasks
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

There are a few issues with your implementations you need to address before this can land.

CHANGELOG.md Outdated

* Teststate enhancement.
[@aydinomer00](https://github.com/aydinomer00)
[#5920](https://github.com/realm/SwiftLint/issues/5920)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be a link to the issue describing the enhancement, not the PR implementing it:

Suggested change
[#5920](https://github.com/realm/SwiftLint/issues/5920)
[#5803](https://github.com/realm/SwiftLint/issues/5803)

CHANGELOG.md Outdated
@@ -7958,3 +7958,9 @@ This release has seen a phenomenal uptake in community contributions!
## 0.1.0: Fresh Out Of The Dryer

First Version!

* Teststate enhancement.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This entry needs to go right to the top of this file.

@@ -58,7 +59,7 @@ struct QuickDiscouragedCallRule: OptInRule {
reason: "Discouraged call inside a '\(name)' block")
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove.

@@ -47,6 +47,7 @@ struct QuickDiscouragedCallRule: OptInRule {
guard
kind == .call,
let name = dictionary.name,
name != "@TestState", // İstisna: @TestState için uyarı tetiklenmesin
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use English for comments.

I don't think this fix is correct. name will never be @TestState. These are the names of Quick methods, not variables or attributes.


// Example of incorrect usage (should trigger a warning)
let triggeringExamples = [
"describe(\"foo\") { @TestState var foo = Foo() }" // This should trigger a warning
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not the correct expectation. With the @TestState we don't expect a warning. This is what #5803 is all about.

import XCTest
@testable import SwiftLintFramework

class QuickDiscouragedCallRuleTests: XCTestCase {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This new test class is not required. Please use QuickDiscouragedCallRuleExamples instead to add your test cases.

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.

Allow @TestState properties be declared inside describe and context
3 participants