realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.55k stars 2.21k forks source link

Support tabs in vertical parameter alignment rule #1573

Open DevAndArtist opened 7 years ago

DevAndArtist commented 7 years ago

My swift files are formatted using AppCode and tabs. Therefore only a few spaces are added automatically when necessary:

private func snap(label: UILabel,
                  below otherView: UIView,
                  offsetBy value: CGFloat) -> [NSLayoutConstraintInterface] {

In Xcode, AppCode and SublimeText these labels are aligned. Tab and ident width is 4.

SwiftLint version: 0.18.1 If I'm not mistaken, GitHub uses a tab width of 8.

DevAndArtist commented 7 years ago

Well I managed to solve the problem using smart tabs in AppCode which matches the behavior of Xcode as well. You can consider this issue as resolved. 🙈

marcelofabri commented 7 years ago

I'm glad that you figured this out, but anyway we probably should support tabs as well

DevAndArtist commented 6 years ago

@marcelofabri I'm confused, some tabs works other don't. Now I bumped into that issue in Xcode as well.

New Issue Checklist

Bug Report

opt_in_rules:
  - closure_end_indentation
  - closure_spacing
  - fatal_error_message
  - force_unwrapping
  - sorted_imports
  - operator_usage_whitespace
  - redundant_nil_coalescing
  - switch_case_on_newline
  - attributes
  - no_extension_access_modifier
  - implicit_return

# rule identifiers to exclude from running
disabled_rules: 
  - colon
  - closure_parameter_position
  - opening_brace
  - file_length
  - implicit_return
  - private_over_fileprivate

# paths to ignore during linting
excluded: 
  - Pods

identifier_name:
  # excluded via string array
  excluded: 
    - px
    - s
    - f
    - ec
    - wb
    - tv
    - av
    - fn

large_tuple: 4

cyclomatic_complexity: 20

nesting:
  type_level: 2

trailing_whitespace:
  ignores_empty_lines: true
  ignores_comments: true

attributes:
  always_on_same_line: ["@IBAction", "@IBOutlet", "@IBInspectable"]
  always_on_line_above: ["@IBDesignable", "@UIApplicationMain", "@discardableResult", "@objc"]
im-jersh commented 6 years ago

I'm confused, this issue is closed but my linter is still throwing warning for this rule in both function and initializers.

paths to ignore during linting. Takes precedence over included.

excluded:

custom rules and overrides

identifier_name: excluded:

line_length: 200

attributes: always_on_same_line: ["@IBAction", "@IBOutlet", "@IBInspectable"] always_on_line_above: ["@IBInspectable", "@UIApplicationMain", "@discardableResult", "@objc"]


- Xcode version: Version 9.2 (9C40b)
Code that reproduces the issue:
``` swift
final internal class FieldEnvironment: FieldEnvironmentInterface {
    init(environment: Environment,
         sitesPersistence: SitesPersistenceInterface,
         sitesDownloader: SitesDownloaderInterface,
         plotsPersistence: PlotsPersistenceInterface,
         plotsDownloader: PlotsDownloaderInterface) {
            self.environment = environment
        self.sitesPersistence = sitesPersistence
        self.sitesDownloader = sitesDownloader
        self.plotsPersistence = plotsPersistence
        self.plotsDownloader = plotsDownloader
    }
}
marcelofabri commented 6 years ago

@oriyentel This issue is not closed 🤔

corcoja commented 6 years ago

@marcelofabri, any chances this is going to be resolved? The tabs also affect the line_length rule, which treats tab as a single character (which it is) but visually is shown as 4 spaces in Xcode (by default), see example below.

screen shot 2018-06-27 at 3 53 07 pm

Line with tabs has 61 characters, line with spaces has 67.

marcelofabri commented 6 years ago

@iuliancorcoja feel free to send a PR!

ikesyo commented 6 years ago

This also applies to vertical_parameter_alignment_on_call rule.

MichalAlgor commented 5 years ago

Hi! I'm trying to fix this bug but came across some problems, is there anyone I can reach out to who can help? I figured out that when tabs are in the string being validate the offset is wrong as in VerticalParameterAlignmentRule the lineAndCharacter function is called with the expandingTabsToWidth default value (1). But I have no idea where to go from now.

stale[bot] commented 3 years ago

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!

MaximillionMai commented 3 years ago

@marcelofabri May I know if this issue will be fixed?

henryglendening-hh commented 2 years ago

Looks like this issue is closed, however it has not yet been fixed. Has anyone achieved a workaround in the meantime?

MaximillionMai commented 2 years ago

Is there a way to reopen this? Or we should just open a new issue?

futuretap commented 2 years ago

Please reopen, @marcelofabri, I'm still affected, only using Xcode with tabs.

bwdavis11 commented 1 year ago

Still having this issue

importRyan commented 10 months ago

Likewise. Tabs == accessibility feature