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

Improve type_name rule violations to be positioned on the type name #2023

Merged
merged 1 commit into from
Jan 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
[Marcelo Fabri](https://github.com/marcelofabri)
[#2021](https://github.com/realm/SwiftLint/issues/2021)

* Improve `type_name` rule violations to be positioned on the type name.
[Marcelo Fabri](https://github.com/marcelofabri)
[#2021](https://github.com/realm/SwiftLint/issues/2021)

## 0.24.2: Dented Tumbler

#### Breaking
Expand Down
30 changes: 15 additions & 15 deletions Rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -15464,63 +15464,63 @@ case value
<summary>Triggering Examples</summary>

```swift
class myType {}
class myType {}
```

```swift
class _MyType {}
class _MyType {}
```

```swift
private class MyType_ {}
private class MyType_ {}
```

```swift
class My {}
class My {}
```

```swift
class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {}
class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {}
```

```swift
struct myType {}
struct myType {}
```

```swift
struct _MyType {}
struct _MyType {}
```

```swift
private struct MyType_ {}
private struct MyType_ {}
```

```swift
struct My {}
struct My {}
```

```swift
struct AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {}
struct AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {}
```

```swift
enum myType {}
enum myType {}
```

```swift
enum _MyType {}
enum _MyType {}
```

```swift
private enum MyType_ {}
private enum MyType_ {}
```

```swift
enum My {}
enum My {}
```

```swift
enum AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {}
enum AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {}
```

```swift
Expand Down
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Rules/TypeNameRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct TypeNameRule: ASTRule, ConfigurationProviderRule {

guard typeKinds.contains(kind),
let name = dictionary.name,
let offset = dictionary.offset else {
let offset = dictionary.nameOffset else {
return []
}

Expand Down
10 changes: 5 additions & 5 deletions Source/SwiftLintFramework/Rules/TypeNameRuleExamples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ internal struct TypeNameRuleExamples {
static let triggeringExamples: [String] = {
let typeExamples: [String] = types.flatMap { (type: String) -> [String] in
[
"\(type) myType {}",
"\(type) _MyType {}",
"private \(type) MyType_ {}",
"\(type) My {}",
"\(type) \(repeatElement("A", count: 41).joined()) {}"
"\(type) myType {}",
"\(type) _MyType {}",
"private \(type) MyType_ {}",
"\(type) My {}",
"\(type) \(repeatElement("A", count: 41).joined()) {}"
]
}
let typeAliasAndAssociatedTypeExamples: [String] = [
Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftLintFrameworkTests/TypeNameRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TypeNameRuleTests: XCTestCase {
func testTypeNameWithAllowedSymbolsAndViolation() {
let baseDescription = TypeNameRule.description
let triggeringExamples = [
"class My_Type$ {}"
"class My_Type$ {}"
]

let description = baseDescription.with(triggeringExamples: triggeringExamples)
Expand All @@ -43,9 +43,9 @@ class TypeNameRuleTests: XCTestCase {
let baseDescription = TypeNameRule.description
let triggeringExamplesToRemove = [
"private typealias ↓foo = Void",
"class myType {}",
"struct myType {}",
"enum myType {}"
"class myType {}",
"struct myType {}",
"enum myType {}"
]
let nonTriggeringExamples = baseDescription.nonTriggeringExamples +
triggeringExamplesToRemove.map { $0.replacingOccurrences(of: "↓", with: "") }
Expand Down