SwiftLint
SwiftLint copied to clipboard
Support tabs in vertical parameter alignment rule
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.
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. 🙈
I'm glad that you figured this out, but anyway we probably should support tabs as well
@marcelofabri I'm confused, some tabs works other don't. Now I bumped into that issue in Xcode as well.
New Issue Checklist
- [x] Updated SwiftLint to the latest version
- [x] I searched for existing GitHub issues
Bug Report
- SwiftLint version: 0.24.0
- Installation method used: CocoaPods
- Configuration file:
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"]
- Xcode version: Version 9.1 (9B55)
- Code that reproduces the issue:
struct Test {
init(x _: Int,
y _: Int,
z _: Int) {
print("""
y and z lines are indeded by Xcode via `control + i`
Vertical Parameter Alignment Violation: Function parameters should be aligned \
vertically if they're in multiple lines in a declaration. (vertical_parameter_alignment)
""")
}
}
I'm confused, this issue is closed but my linter is still throwing warning for this rule in both function and initializers.
- SwiftLint version: 0.24.2
- Installation method used: Homebrew
- Configuration file:
# rule identifiers to exclude from running
disabled_rules:
- trailing_whitespace
- vertical_whitespace
- void_return
- trailing_newline
# paths to ignore during linting. Takes precedence over `included`.
excluded:
- FieldEnvironmentExample
- FieldEnvironmentKitTests
# custom rules and overrides
identifier_name:
excluded:
- id
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:
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
}
}
@oriyentel This issue is not closed 🤔
@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](https://user-images.githubusercontent.com/8669879/41978467-3ef8efb6-7a22-11e8-8667-c308592224b8.png)
Line with tabs has 61 characters, line with spaces has 67.
@iuliancorcoja feel free to send a PR!
This also applies to vertical_parameter_alignment_on_call
rule.
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.
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!
@marcelofabri May I know if this issue will be fixed?
Looks like this issue is closed, however it has not yet been fixed. Has anyone achieved a workaround in the meantime?
Is there a way to reopen this? Or we should just open a new issue?
Please reopen, @marcelofabri, I'm still affected, only using Xcode with tabs.
Still having this issue
Likewise. Tabs == accessibility feature