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

autocorrect fix of locally disabled rules #724

Closed
wants to merge 4 commits into from

Conversation

masters3d
Copy link
Contributor

This code needs to be added to all the correctable rules that don't have it, but I think we should probably add this to the File type or Correctable protocol so that we could just say

if currentRuleIsDisabled{
   return []
}

closes #601

@codecov-io
Copy link

codecov-io commented Jul 13, 2016

Current coverage is 88.87%

Merging #724 into master will decrease coverage by 0.58%

@@             master       #724   diff @@
==========================================
  Files            72         72          
  Lines          2391       2410    +19   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2139       2142     +3   
- Misses          252        268    +16   
  Partials          0          0          

Powered by Codecov. Last updated by cccfef7...14d92c3

TODO: adopt isRuleDisabled(file:File) from CorrectableRule Protocol in
TrailingWhitespaceRule.swift. I didn’t take the time to change it.
@masters3d masters3d changed the title autocorrect fix of locally disabled comma rule autocorrect fix of locally disabled rules Jul 13, 2016
@masters3d
Copy link
Contributor Author

I went ahead and generalized this on the correctable protocol.

I am thinking we should probably do something like this with the protocol.

public protocol CorrectableRule: Rule {
    func correctFile(file: File) -> [Correction] // this has a default implementation
    func correctFileConfiguration(file: File) -> [Correction] // this gets implemented
}

extension CorrectableRule {
    private func isRuleDisabled(file: File) -> Bool {}// private default implementation
    func correctFile(file: File) -> [Correction]{
        if isRuleDisabled(file) { return [] }
        correctFileConfiguration(file)
}

@masters3d
Copy link
Contributor Author

Closing this: I am disabling the rules per file based and not per region based. I will update and submit a new PR.

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.

Autocorrect corrects parts that are wrapped with swiftlint-disable
2 participants