Browse code

pkg/file{utils,notify}: don't compare to bool

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>

unclejack authored on 2017/03/30 18:12:17
Showing 2 changed files
... ...
@@ -44,7 +44,7 @@ func (w *filePoller) Add(name string) error {
44 44
 	w.mu.Lock()
45 45
 	defer w.mu.Unlock()
46 46
 
47
-	if w.closed == true {
47
+	if w.closed {
48 48
 		return errPollerClosed
49 49
 	}
50 50
 
... ...
@@ -78,7 +78,7 @@ func (w *filePoller) Remove(name string) error {
78 78
 }
79 79
 
80 80
 func (w *filePoller) remove(name string) error {
81
-	if w.closed == true {
81
+	if w.closed {
82 82
 		return errPollerClosed
83 83
 	}
84 84
 
... ...
@@ -208,7 +208,7 @@ func TestReadSymlinkedDirectoryToFile(t *testing.T) {
208 208
 
209 209
 func TestWildcardMatches(t *testing.T) {
210 210
 	match, _ := Matches("fileutils.go", []string{"*"})
211
-	if match != true {
211
+	if !match {
212 212
 		t.Errorf("failed to get a wildcard match, got %v", match)
213 213
 	}
214 214
 }
... ...
@@ -216,7 +216,7 @@ func TestWildcardMatches(t *testing.T) {
216 216
 // A simple pattern match should return true.
217 217
 func TestPatternMatches(t *testing.T) {
218 218
 	match, _ := Matches("fileutils.go", []string{"*.go"})
219
-	if match != true {
219
+	if !match {
220 220
 		t.Errorf("failed to get a match, got %v", match)
221 221
 	}
222 222
 }
... ...
@@ -224,7 +224,7 @@ func TestPatternMatches(t *testing.T) {
224 224
 // An exclusion followed by an inclusion should return true.
225 225
 func TestExclusionPatternMatchesPatternBefore(t *testing.T) {
226 226
 	match, _ := Matches("fileutils.go", []string{"!fileutils.go", "*.go"})
227
-	if match != true {
227
+	if !match {
228 228
 		t.Errorf("failed to get true match on exclusion pattern, got %v", match)
229 229
 	}
230 230
 }
... ...
@@ -232,7 +232,7 @@ func TestExclusionPatternMatchesPatternBefore(t *testing.T) {
232 232
 // A folder pattern followed by an exception should return false.
233 233
 func TestPatternMatchesFolderExclusions(t *testing.T) {
234 234
 	match, _ := Matches("docs/README.md", []string{"docs", "!docs/README.md"})
235
-	if match != false {
235
+	if match {
236 236
 		t.Errorf("failed to get a false match on exclusion pattern, got %v", match)
237 237
 	}
238 238
 }
... ...
@@ -240,7 +240,7 @@ func TestPatternMatchesFolderExclusions(t *testing.T) {
240 240
 // A folder pattern followed by an exception should return false.
241 241
 func TestPatternMatchesFolderWithSlashExclusions(t *testing.T) {
242 242
 	match, _ := Matches("docs/README.md", []string{"docs/", "!docs/README.md"})
243
-	if match != false {
243
+	if match {
244 244
 		t.Errorf("failed to get a false match on exclusion pattern, got %v", match)
245 245
 	}
246 246
 }
... ...
@@ -248,7 +248,7 @@ func TestPatternMatchesFolderWithSlashExclusions(t *testing.T) {
248 248
 // A folder pattern followed by an exception should return false.
249 249
 func TestPatternMatchesFolderWildcardExclusions(t *testing.T) {
250 250
 	match, _ := Matches("docs/README.md", []string{"docs/*", "!docs/README.md"})
251
-	if match != false {
251
+	if match {
252 252
 		t.Errorf("failed to get a false match on exclusion pattern, got %v", match)
253 253
 	}
254 254
 }
... ...
@@ -256,7 +256,7 @@ func TestPatternMatchesFolderWildcardExclusions(t *testing.T) {
256 256
 // A pattern followed by an exclusion should return false.
257 257
 func TestExclusionPatternMatchesPatternAfter(t *testing.T) {
258 258
 	match, _ := Matches("fileutils.go", []string{"*.go", "!fileutils.go"})
259
-	if match != false {
259
+	if match {
260 260
 		t.Errorf("failed to get false match on exclusion pattern, got %v", match)
261 261
 	}
262 262
 }
... ...
@@ -264,7 +264,7 @@ func TestExclusionPatternMatchesPatternAfter(t *testing.T) {
264 264
 // A filename evaluating to . should return false.
265 265
 func TestExclusionPatternMatchesWholeDirectory(t *testing.T) {
266 266
 	match, _ := Matches(".", []string{"*.go"})
267
-	if match != false {
267
+	if match {
268 268
 		t.Errorf("failed to get false match on ., got %v", match)
269 269
 	}
270 270
 }
... ...
@@ -573,7 +573,7 @@ func TestMatch(t *testing.T) {
573 573
 		pattern := tt.pattern
574 574
 		s := tt.s
575 575
 		if runtime.GOOS == "windows" {
576
-			if strings.Index(pattern, "\\") >= 0 {
576
+			if strings.Contains(pattern, "\\") {
577 577
 				// no escape allowed on windows.
578 578
 				continue
579 579
 			}