Catch internal vars
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- [x ] Updated SwiftLint to the latest version
- [x ] I searched for existing GitHub issues
Describe the bug
The ideia is to find internal vars on the code, but for some reason is not catching group 4, does SwiftLint support name grouping like ? and on yml capture_group: "internal"? the regex is working on Xcode 11 regex find
Complete output when running SwiftLint, including the stack trace and command used
original regex
(.*\n)*?class\s\w*\s?[:](\s+\w*[:, {])*\{\n(.*\n)*?((\s{4}|\t)(internal\s)?((weak|lazy)\s)?(var|let))
//
// Copyright © whatever
//
import Foundation
open class SomeViewModel: NSObject {
open var someService: SomeService
public init(someService: SomeService) {
self.someService = SomeService
}
//internal var stuff = 1 // <--if uncommented should catch this one
open var stuff12 = 1
internal var stuff = 1 // <--should catch this one
}
Environment
- SwiftLint running on Xcode with custom rules
internal_acl:
included: ".*((View|ViewController|ViewModel|Cell).swift)\\b$"
name: "Delivery Internal access level"
regex: "(.*\\n)*?class\\s\\w*\\s?[:](\\s+\\w*[:, {])*\\{\\n(.*\\n)*?((\\s{4}|\\t)(internal\\s)?((weak|lazy)\\s)?(var|let))"
capture_group: 4
message: "Please make sure to not use internal access level so that delivery could customize or access this variable.For more information check https://wiki.smithmicro.net/display/SP/iOS+Extensibility+Guidelines"
severity: error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the supplied custom-rule YAML and Swift sample, then inspect SwiftLint's custom regex rule handling and capture_group parsing. No repository file or test is named in the issue; compare the configured group 4 with the existing behavior. Done means the internal declaration is consistently caught or the supported configuration is established by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100