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

Add autocorrect for control_statement #2303

Closed
wants to merge 6 commits into from

Conversation

colejd
Copy link

@colejd colejd commented Jul 20, 2018

Hello! This adds autocorrect support for the control_statement rule.

Caveat:
As of now, it only seems to get the outermost control blocks it can find that break the rule; to fully correct, you need to run autocorrect a few times. If anyone has a way around this, I'd love to get that in here.

Thank you!

@SwiftLintBot
Copy link

SwiftLintBot commented Jul 20, 2018

1 Warning
⚠️ This PR may need tests.
12 Messages
📖 Linting Aerial with this PR took 0.4s vs 0.38s on master (5% slower)
📖 Linting Alamofire with this PR took 3.62s vs 3.28s on master (10% slower)
📖 Linting Firefox with this PR took 14.06s vs 12.24s on master (14% slower)
📖 Linting Kickstarter with this PR took 22.05s vs 17.31s on master (27% slower)
📖 Linting Moya with this PR took 2.27s vs 1.89s on master (20% slower)
📖 Linting Nimble with this PR took 2.18s vs 1.69s on master (28% slower)
📖 Linting Quick with this PR took 0.61s vs 0.5s on master (21% slower)
📖 Linting Realm with this PR took 3.93s vs 3.28s on master (19% slower)
📖 Linting SourceKitten with this PR took 1.15s vs 1.01s on master (13% slower)
📖 Linting Sourcery with this PR took 5.34s vs 4.5s on master (18% slower)
📖 Linting Swift with this PR took 30.75s vs 27.53s on master (11% slower)
📖 Linting WordPress with this PR took 18.25s vs 15.77s on master (15% slower)

Generated by 🚫 Danger

@colejd
Copy link
Author

colejd commented Jul 20, 2018

It’s apparent now that there’s some optimization work that needs to be done. Also, my paren matching depends on String.Index being hashable, which isn’t the case in Swift 4. I’ll find fixes for these tonight.

@colejd colejd force-pushed the control-statement-autocorrect branch from f2dbaf8 to 5c3be65 Compare July 23, 2018 20:28
@codecov-io
Copy link

codecov-io commented Jul 23, 2018

Codecov Report

Merging #2303 into master will increase coverage by 0.03%.
The diff coverage is 96.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2303      +/-   ##
==========================================
+ Coverage   91.98%   92.02%   +0.03%     
==========================================
  Files         294      294              
  Lines       14805    14876      +71     
==========================================
+ Hits        13619    13689      +70     
- Misses       1186     1187       +1
Impacted Files Coverage Δ
...wiftLintFramework/Rules/ControlStatementRule.swift 96.49% <96.62%> (-1.19%) ⬇️
Source/SwiftLintFramework/Models/Command.swift 98.7% <0%> (+1.29%) ⬆️
...iftLintFramework/Extensions/String+SwiftLint.swift 91.07% <0%> (+1.78%) ⬆️

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 e9c6d6a...89c3f17. Read the comment docs.

@colejd colejd force-pushed the control-statement-autocorrect branch 3 times, most recently from 423e64b to 9712d8e Compare July 24, 2018 14:08
@colejd colejd force-pushed the control-statement-autocorrect branch from 9712d8e to 89c3f17 Compare July 24, 2018 14:57
@colejd
Copy link
Author

colejd commented Jul 24, 2018

Okay, this is now in a state I would consider ready for review. Thank you for your time!

@colejd
Copy link
Author

colejd commented Jul 25, 2018

Ugh. Something I did between "update changelog" and "optimize correction and validation" breaks autocorrect on production code, even though all the tests pass. Will investigate.

@Jeehut
Copy link
Collaborator

Jeehut commented Feb 25, 2019

@colejd Any updates on this? I'd be happy to review once you consider this ready for review again!

@stale
Copy link

stale bot commented Nov 8, 2020

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

@stale stale bot added the wontfix label Nov 8, 2020
@stale stale bot closed this Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants