{"action":"created","issue":{"url":"https://api.github.com/repos/realm/SwiftLint/issues/2765","repository_url":"https://api.github.com/repos/realm/SwiftLint","labels_url":"https://api.github.com/repos/realm/SwiftLint/issues/2765/labels{/name}","comments_url":"https://api.github.com/repos/realm/SwiftLint/issues/2765/comments","events_url":"https://api.github.com/repos/realm/SwiftLint/issues/2765/events","html_url":"https://github.com/realm/SwiftLint/pull/2765","id":446464014,"node_id":"MDExOlB1bGxSZXF1ZXN0MjgwNjU5MDAz","number":2765,"title":"Add new indentation_width rule","user":{"login":"fredpi","id":19194800,"node_id":"MDQ6VXNlcjE5MTk0ODAw","avatar_url":"https://avatars2.githubusercontent.com/u/19194800?v=4","gravatar_id":"","url":"https://api.github.com/users/fredpi","html_url":"https://github.com/fredpi","followers_url":"https://api.github.com/users/fredpi/followers","following_url":"https://api.github.com/users/fredpi/following{/other_user}","gists_url":"https://api.github.com/users/fredpi/gists{/gist_id}","starred_url":"https://api.github.com/users/fredpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredpi/subscriptions","organizations_url":"https://api.github.com/users/fredpi/orgs","repos_url":"https://api.github.com/users/fredpi/repos","events_url":"https://api.github.com/users/fredpi/events{/privacy}","received_events_url":"https://api.github.com/users/fredpi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2019-05-21T07:41:01Z","updated_at":"2019-12-17T15:43:44Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/realm/SwiftLint/pulls/2765","html_url":"https://github.com/realm/SwiftLint/pull/2765","diff_url":"https://github.com/realm/SwiftLint/pull/2765.diff","patch_url":"https://github.com/realm/SwiftLint/pull/2765.patch"},"body":"It's been a while since https://github.com/realm/SwiftLint/issues/227 has last been discussed and it seems that an advanced indentation rule is somehow also pending some clarification on Xcode's side. However, since this issue has been open for such a long time, I thought about adding a basic additive indentation rule that only does the following things:\r\n\r\n- Check whether the next line is on the same level as the previous line or one tab or `n` spaces indented (where `n` can be configured via `indentation_width`) or unindented keeping the grid.\r\n- Check whether the first line is not indented.\r\n- Check whether spaces and tabs aren't mixed up in one line's indentation.\r\n\r\nThis PR implements such a basic rule. I tested it with a large project we have in our company and found out that it matches the indentation style we already pursued before:\r\n\r\n```\r\nlet testStruct = TestStruct(\r\n    name: \"Test\",\r\n    indentation: \"Cool\"\r\n)\r\n```\r\n\r\nHowever, this rule won't be compatible with other indentation styles like the one Xcode does by default:\r\n\r\n```\r\nlet testStruct = TestStruct(name: \"Test\",\r\n                            indentation: \"Cool\")\r\n```\r\n\r\nThat's why this is an opt-in rule. As such, it won't do harm to those following another indentation style, yet enable built-in indentation linting for those who follow this basic additive pattern. Previously, we had implemented such a rule using multiple regexes that checked for indentation but didn't always work properly, so having this built-in is definitely a plus.\r\n\r\nI want to mention that, according to this rule, unindentation can not only be done by one step (~ `indentation_width` spaces), but also by multiples of one step. This is to allow for the following indentation which I consider valid:\r\n\r\n```\r\nif\r\n    let myLet = someBool ?\r\n        myLet1 :\r\n        myLet2\r\n{\r\n    // Do something with myLet\r\n} \r\n```"},"comment":{"url":"https://api.github.com/repos/realm/SwiftLint/issues/comments/566597744","html_url":"https://github.com/realm/SwiftLint/pull/2765#issuecomment-566597744","issue_url":"https://api.github.com/repos/realm/SwiftLint/issues/2765","id":566597744,"node_id":"MDEyOklzc3VlQ29tbWVudDU2NjU5Nzc0NA==","user":{"login":"fredpi","id":19194800,"node_id":"MDQ6VXNlcjE5MTk0ODAw","avatar_url":"https://avatars2.githubusercontent.com/u/19194800?v=4","gravatar_id":"","url":"https://api.github.com/users/fredpi","html_url":"https://github.com/fredpi","followers_url":"https://api.github.com/users/fredpi/followers","following_url":"https://api.github.com/users/fredpi/following{/other_user}","gists_url":"https://api.github.com/users/fredpi/gists{/gist_id}","starred_url":"https://api.github.com/users/fredpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredpi/subscriptions","organizations_url":"https://api.github.com/users/fredpi/orgs","repos_url":"https://api.github.com/users/fredpi/repos","events_url":"https://api.github.com/users/fredpi/events{/privacy}","received_events_url":"https://api.github.com/users/fredpi/received_events","type":"User","site_admin":false},"created_at":"2019-12-17T15:43:44Z","updated_at":"2019-12-17T15:43:44Z","author_association":"CONTRIBUTOR","body":"Rebasing this every 3 weeks or so is getting frustrating...\r\n\r\nIf nobody has time to review this, maybe one could give me push access so that I can self-review and merge thereafter...\r\nAs this is just an opt-in-rule, it doesn't do any harm..."}}
{"actor":{"display_login":"fredpi"}}