0

Here is my rule:

custom_rules:
  protocol_single_responsibility_violation:
    name: "Protocol with more than one function and or variable"
    regex: '(protocol.*\{\n.*func.*\n.*func.*\})|(protocol.*\{\n.*var.*\n.*func.*\})|(protocol.*\{\n.*func.*\n.*var.*\})|(protocol.*\{\n.*var.*\n.*var.*\})'
    message: "If you would like to create a protocol with more than one function and or variable, then cretae separate protocols with one function or variable each, then combine them with a typealias. For example, typealias = firstProtocol & secondProtocol"
    severity: error

Here is my test


protocol GroupedProtocol { // This is the only one it catches
    func stuff()
    func stuff2()
}

protocol GroupedProtocol2 {
    var stuff: Int { get set }
    func stuff2()
}

protocol GroupedProtocol3 {
    var stuff: Int { get set }
    var stuff2: Int { get set }
}

protocol GroupedProtocol4 {
    func stuff2()
    var stuff: Int { get set }
}

protocol GroupedProtocol5 {
    func stuff()
}

class Decoy { }

Its currently matching only one of the cases. How can I make it match all 4 cases?

ScottyBlades
  • 12,189
  • 5
  • 77
  • 85

0 Answers0