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

Fix some false positives in rule explicit_self #3368

Conversation

svenmuennich
Copy link
Contributor

Some accesses to instance properties attributed with a property wrapper resulted in false positives for rule explicit_self. This was caused by only checking the character directly preceding the member access to be a .. Hence accesses to a projected value of a wrapped property (e.g. self.$foo) or the property wrapper itself (e.g. self._foo) failed the test.

@SwiftLintBot
Copy link

1 Warning
⚠️ This PR may need tests.
12 Messages
📖 Linting Aerial with this PR took 0.8s vs 0.79s on master (1% slower)
📖 Linting Alamofire with this PR took 1.0s vs 0.98s on master (2% slower)
📖 Linting Firefox with this PR took 3.94s vs 3.78s on master (4% slower)
📖 Linting Kickstarter with this PR took 6.54s vs 6.32s on master (3% slower)
📖 Linting Moya with this PR took 0.52s vs 0.5s on master (4% slower)
📖 Linting Nimble with this PR took 0.58s vs 0.58s on master (0% slower)
📖 Linting Quick with this PR took 0.33s vs 0.3s on master (10% slower)
📖 Linting Realm with this PR took 1.14s vs 1.11s on master (2% slower)
📖 Linting SourceKitten with this PR took 0.51s vs 0.49s on master (4% slower)
📖 Linting Sourcery with this PR took 2.59s vs 2.55s on master (1% slower)
📖 Linting Swift with this PR took 8.09s vs 8.03s on master (0% slower)
📖 Linting WordPress with this PR took 7.26s vs 7.04s on master (3% slower)

Generated by 🚫 Danger

@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2020

Codecov Report

Merging #3368 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3368   +/-   ##
=======================================
  Coverage   90.53%   90.54%           
=======================================
  Files         417      417           
  Lines       20497    20508   +11     
=======================================
+ Hits        18557    18568   +11     
  Misses       1940     1940           
Impacted Files Coverage Δ
...ftLintFramework/Rules/Style/ExplicitSelfRule.swift 89.28% <100.00%> (+1.61%) ⬆️

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 15c25ab...65d49df. Read the comment docs.

@jpsim
Copy link
Collaborator

jpsim commented Sep 25, 2020

Awesome PR, Thanks!

@jpsim jpsim merged commit da408b5 into realm:master Sep 25, 2020
@svenmuennich svenmuennich deleted the svenmuennich/fix-false-positive-in-rule-explicit-self branch September 26, 2020 12:31
optionalendeavors added a commit to optionalendeavors/SwiftLint that referenced this pull request Oct 4, 2020
* master-upstream: (98 commits)
  Fix some false positives in rule `explicit_self` (realm#3368)
  Update SourceKitten to 0.30.1 (realm#3367)
  Fix issues with analyzer rules, Xcode 12 & SwiftUI (realm#3366)
  Add empty changelog section
  release 0.40.3
  Fix false positives for 'multiple_closures_with_trailing_closure' (realm#3353)
  [UnusedDeclarationRule] Work around SR-11985 (realm#3363)
  Revert "Fix finding the nested config when a single file path is passed (realm#3342)" (realm#3362)
  [CONTRIBUTING] Add building & running tips (realm#3360)
  Fix finding the nested config when a single file path is passed (realm#3342)
  Include Linux zip in list of GitHub release binaries (realm#3350)
  [UnusedDeclarationRule] Add more tests (realm#3359)
  Test CI with official Swift 5.3 release (realm#3356)
  Don't mark `@NSApplicationMain` or `@UIApplicationMain` classes as unused (realm#3355)
  [Fix] `UnusedCaptureListRule`: implicit self in @escaping closures (realm#3352)
  Skip correcting files with parser diagnostics (realm#3349)
  [SwiftLintFile] Remove lock in favor of UUID (realm#3347)
  [UnusedDeclarationRule] Speed up and detect more dead code (realm#3340)
  Add empty changelog section
  release 0.40.2
  ...

# Conflicts:
#	Source/swiftlint/Helpers/LintableFilesVisitor.swift
optionalendeavors added a commit to optionalendeavors/SwiftLint that referenced this pull request Oct 4, 2020
* master: (98 commits)
  Fix some false positives in rule `explicit_self` (realm#3368)
  Update SourceKitten to 0.30.1 (realm#3367)
  Fix issues with analyzer rules, Xcode 12 & SwiftUI (realm#3366)
  Add empty changelog section
  release 0.40.3
  Fix false positives for 'multiple_closures_with_trailing_closure' (realm#3353)
  [UnusedDeclarationRule] Work around SR-11985 (realm#3363)
  Revert "Fix finding the nested config when a single file path is passed (realm#3342)" (realm#3362)
  [CONTRIBUTING] Add building & running tips (realm#3360)
  Fix finding the nested config when a single file path is passed (realm#3342)
  Include Linux zip in list of GitHub release binaries (realm#3350)
  [UnusedDeclarationRule] Add more tests (realm#3359)
  Test CI with official Swift 5.3 release (realm#3356)
  Don't mark `@NSApplicationMain` or `@UIApplicationMain` classes as unused (realm#3355)
  [Fix] `UnusedCaptureListRule`: implicit self in @escaping closures (realm#3352)
  Skip correcting files with parser diagnostics (realm#3349)
  [SwiftLintFile] Remove lock in favor of UUID (realm#3347)
  [UnusedDeclarationRule] Speed up and detect more dead code (realm#3340)
  Add empty changelog section
  release 0.40.2
  ...
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.

4 participants