Skip to content

Commit 4744f45

Browse files
committed
Update introduction in README
1 parent a602aa4 commit 4744f45

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ included:
55
- Tests
66
- Package.swift
77
excluded:
8+
- assets
89
- Tests/BuiltInRulesTests/Resources
910
- Tests/FileSystemAccessTests/Resources
1011

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ SwiftLint enforces the style guide rules that are generally accepted by the
66
Swift community. These rules are well described in popular style guides like
77
[Kodeco's Swift Style Guide](https://github.com/kodecocodes/swift-style-guide).
88

9-
SwiftLint hooks into [Clang](http://clang.llvm.org) and
10-
[SourceKit](http://www.jpsim.com/uncovering-sourcekit) to use the
11-
[AST](http://clang.llvm.org/docs/IntroductionToTheClangAST.html) representation
12-
of your source files for more accurate results.
9+
SwiftLint rules are predominantly based on [SwiftSyntax](https://github.com/swiftlang/swift-syntax).
10+
Some rules still hook into [Clang](http://clang.llvm.org) and
11+
[SourceKit](http://www.jpsim.com/uncovering-sourcekit) to access type information.
1312

1413
[![Supported Swift Versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Frealm%2FSwiftLint%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/realm/SwiftLint)
1514
[![Supported Platforms](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Frealm%2FSwiftLint%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/realm/SwiftLint)
@@ -22,7 +21,7 @@ This project adheres to the
2221
By participating, you are expected to uphold this code.
2322

2423
> Switch Language:
25-
> [中文](https://github.com/realm/SwiftLint/blob/main/README_CN.md)
24+
> [中文](https://github.com/realm/SwiftLint/blob/main/README_CN.md),
2625
> [한국어](https://github.com/realm/SwiftLint/blob/main/README_KR.md)
2726
2827
## Video Introduction

assets/ScreenshotExample.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
3+
class MyViewController : UIViewController { // space before colon
4+
var userName:String = "" // no space after colon; redundant type
5+
let x = 5 // short variable name
6+
7+
func doSomething(arg: Int) { // unused parameter
8+
let result = userName as! String // force cast
9+
10+
if(result.count > 0) { // control statement parentheses; use !isEmpty
11+
print("User name is not empty")
12+
}
13+
14+
// try! someRiskyOperation() // SwiftLint is syntax-aware -> no violation here
15+
try! someRiskyOperation() // force try
16+
}
17+
18+
func someRiskyOperation() async throws { // unnecessary async; unnecessary throws
19+
// Implementation
20+
}
21+
}

assets/screenshot.png

8.66 KB
Loading

0 commit comments

Comments
 (0)