nolint:cyclop,gocognit // complexity mirrors the upstream actionlint implementation
()
| 85 | |
| 86 | //nolint:cyclop,gocognit // complexity mirrors the upstream actionlint implementation |
| 87 | func (v *globValidator) validateNext() bool { |
| 88 | c := v.scan.Next() |
| 89 | prec := true |
| 90 | |
| 91 | switch c { |
| 92 | case '\\': |
| 93 | switch v.scan.Peek() { |
| 94 | case '[', '?', '*': |
| 95 | c = v.scan.Next() |
| 96 | if v.isRef { |
| 97 | v.invalidRefChar(c, "ref name cannot contain spaces, ~, ^, :, [, ?, *") |
| 98 | } |
| 99 | case '+', '\\', '!': |
| 100 | c = v.scan.Next() |
| 101 | default: |
| 102 | if v.isRef { |
| 103 | v.invalidRefChar('\\', "only special characters [, ?, +, *, \\, ! can be escaped with \\") |
| 104 | c = v.scan.Next() |
| 105 | } |
| 106 | } |
| 107 | case '?': |
| 108 | if !v.prec { |
| 109 | v.unexpected('?', "special character ? (zero or one)", "the preceding character must not be special character") |
| 110 | } |
| 111 | prec = false |
| 112 | case '+': |
| 113 | if !v.prec { |
| 114 | v.unexpected('+', "special character + (one or more)", "the preceding character must not be special character") |
| 115 | } |
| 116 | prec = false |
| 117 | case '*': |
| 118 | prec = false |
| 119 | case '[': |
| 120 | if v.scan.Peek() == ']' { |
| 121 | c = v.scan.Next() |
| 122 | v.unexpected(']', "content of character match []", "character match must not be empty") |
| 123 | break |
| 124 | } |
| 125 | chars := 0 |
| 126 | Loop: |
| 127 | for { |
| 128 | c = v.scan.Next() |
| 129 | switch c { |
| 130 | case ']': |
| 131 | break Loop |
| 132 | case scanner.EOF: |
| 133 | v.unexpected(c, "end of character match []", "missing ]") |
| 134 | return false |
| 135 | default: |
| 136 | if v.scan.Peek() != '-' { |
| 137 | chars++ |
| 138 | continue Loop |
| 139 | } |
| 140 | chars += 2 |
| 141 | s := c |
| 142 | _ = v.scan.Next() // eat '-'; return value not needed |
| 143 | switch v.scan.Peek() { |
| 144 | case ']': |
no test coverage detected