1

I try to exclude all the unit test files. But it does not work. Does SwiftLint support nested exclude?

  - Pods
  - Carthage
  - ".*Tests.swift"
# Errors
force_try: warning #All errors occur in Nimble pod, this can be ignored
force_cast:
  severity: warning
  excluded:
    - "*Tests.swift"
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
benoitcn
  • 149
  • 1
  • 12
  • 1
    What are you trying to exclude, `.*Tests.swift` is not a path but a filename pattern? What about just "Tests" or whatever your root folder for test files is called? – Joakim Danielson Aug 11 '20 at 16:54
  • My project does not have a path that contains all of the tests files. – benoitcn Aug 11 '20 at 23:16
  • Then you add those paths but in a proper way, look at the documentation for some examples.. – Joakim Danielson Aug 12 '20 at 06:27
  • @JoakimDanielson I have a lot of path that containing the test files. Is there a way to use the file name pattern? – benoitcn Aug 12 '20 at 15:48
  • I think you need to work with folders when using exclude or include the path when excluding files. – Joakim Danielson Aug 12 '20 at 16:58
  • @benoitcn do you resolve this question? I encounter the same question. How to exclude all tests file? – Xaree Lee Dec 15 '20 at 03:13
  • @李岡諭 @Joakim Danielson I ended up using the `Find` command to search all the existing .swift files. And format the output of the command by adding the prefix `- ` to each line. – benoitcn Dec 19 '20 at 01:33

1 Answers1

0

You can include folder path in the excluded path section, For nested file workaround, try keeping it in a single folder to exclude the files or mention them in exclude file section.
For Example

excluded: # paths to ignore during linting. Takes precedence over `included`.
  - pH7-DriverTests
  - pH7-DriverUITests
  - Pods

Example:- project's Test & UITest folder name is 'pH7-DriverTest' and 'pH7-DriverUITest' and it contains in source folder. Project file path

Mayank Verma
  • 108
  • 1
  • 8