##// END OF EJS Templates
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler -
r14494:1ffeeb91 default
parent child Browse files
Show More
@@ -163,6 +163,8 b' pypats = ['
163 163 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
164 164 (r' [=!]=\s+(True|False|None)',
165 165 "comparison with singleton, use 'is' or 'is not' instead"),
166 (r'^\s*(while|if) [01]:',
167 "use True/False for constant Boolean expression"),
166 168 (r'opener\([^)]*\).read\(',
167 169 "use opener.read() instead"),
168 170 (r'opener\([^)]*\).write\(',
@@ -8,7 +8,7 b' def timer(func, title=None):'
8 8 results = []
9 9 begin = time.time()
10 10 count = 0
11 while 1:
11 while True:
12 12 ostart = os.times()
13 13 cstart = time.time()
14 14 r = func()
@@ -227,7 +227,7 b' class convert_cvs(converter_source):'
227 227
228 228 data = ""
229 229 mode = None
230 while 1:
230 while True:
231 231 line = self.readp.readline()
232 232 if line.startswith("Created ") or line.startswith("Updated "):
233 233 self.readp.readline() # path
@@ -591,7 +591,7 b' class DNSIncoming(object):'
591 591 next = -1
592 592 first = off
593 593
594 while 1:
594 while True:
595 595 len = ord(self.data[off])
596 596 off += 1
597 597 if len == 0:
@@ -939,7 +939,7 b' class Reaper(threading.Thread):'
939 939 self.start()
940 940
941 941 def run(self):
942 while 1:
942 while True:
943 943 self.zeroconf.wait(10 * 1000)
944 944 if globals()['_GLOBAL_DONE']:
945 945 return
@@ -1003,7 +1003,7 b' class ServiceBrowser(threading.Thread):'
1003 1003 self.zeroconf.notifyAll()
1004 1004
1005 1005 def run(self):
1006 while 1:
1006 while True:
1007 1007 event = None
1008 1008 now = currentTimeMillis()
1009 1009 if len(self.list) == 0 and self.nextTime > now:
@@ -76,7 +76,7 b' def ancestor(a, b, pfunc):'
76 76 # increment each ancestor list until it is closer to root than
77 77 # the other, or they match
78 78 try:
79 while 1:
79 while True:
80 80 if gx[0] == gy[0]:
81 81 for v in gx[1]:
82 82 if v in gy[1]:
@@ -33,7 +33,7 b' class bundlerevlog(revlog.revlog):'
33 33 self.basemap = {}
34 34 n = len(self)
35 35 chain = None
36 while 1:
36 while True:
37 37 chunkdata = bundle.deltachunk(chain)
38 38 if not chunkdata:
39 39 break
@@ -185,7 +185,7 b' class bundlerepository(localrepo.localre'
185 185
186 186 try:
187 187 fptemp.write("HG10UN")
188 while 1:
188 while True:
189 189 chunk = self.bundle.read(2**18)
190 190 if not chunk:
191 191 break
@@ -232,13 +232,13 b' class bundlerepository(localrepo.localre'
232 232 def file(self, f):
233 233 if not self.bundlefilespos:
234 234 self.bundle.seek(self.filestart)
235 while 1:
235 while True:
236 236 chunkdata = self.bundle.filelogheader()
237 237 if not chunkdata:
238 238 break
239 239 fname = chunkdata['filename']
240 240 self.bundlefilespos[fname] = self.bundle.tell()
241 while 1:
241 while True:
242 242 c = self.bundle.deltachunk(None)
243 243 if not c:
244 244 break
@@ -91,7 +91,7 b' def writebundle(cg, filename, bundletype'
91 91 while not empty or count <= 2:
92 92 empty = True
93 93 count += 1
94 while 1:
94 while True:
95 95 chunk = getchunk(cg)
96 96 if not chunk:
97 97 break
@@ -1342,7 +1342,7 b' def debugbundle(ui, bundlepath, all=None'
1342 1342 def showchunks(named):
1343 1343 ui.write("\n%s\n" % named)
1344 1344 chain = None
1345 while 1:
1345 while True:
1346 1346 chunkdata = gen.deltachunk(chain)
1347 1347 if not chunkdata:
1348 1348 break
@@ -1361,7 +1361,7 b' def debugbundle(ui, bundlepath, all=None'
1361 1361 showchunks("changelog")
1362 1362 chunkdata = gen.manifestheader()
1363 1363 showchunks("manifest")
1364 while 1:
1364 while True:
1365 1365 chunkdata = gen.filelogheader()
1366 1366 if not chunkdata:
1367 1367 break
@@ -1370,7 +1370,7 b' def debugbundle(ui, bundlepath, all=None'
1370 1370 else:
1371 1371 chunkdata = gen.changelogheader()
1372 1372 chain = None
1373 while 1:
1373 while True:
1374 1374 chunkdata = gen.deltachunk(chain)
1375 1375 if not chunkdata:
1376 1376 break
@@ -134,7 +134,7 b' def copies(repo, c1, c2, ca, checkdirs=F'
134 134 if f2r is None:
135 135 f2 = g2.next()
136 136
137 while 1:
137 while True:
138 138 f1r, f2r = f1.rev(), f2.rev()
139 139 if f1r > f2r:
140 140 f1 = g1.next()
@@ -33,7 +33,7 b' class webproto(object):'
33 33 args = self.req.form.copy()
34 34 chunks = []
35 35 i = 1
36 while 1:
36 while True:
37 37 h = self.req.env.get('HTTP_X_HGARG_' + str(i))
38 38 if h is None:
39 39 break
@@ -50,7 +50,7 b' class webproto(object):'
50 50 sys.stderr = sys.stdout = cStringIO.StringIO()
51 51 def groupchunks(self, cg):
52 52 z = zlib.compressobj()
53 while 1:
53 while True:
54 54 chunk = cg.read(4096)
55 55 if not chunk:
56 56 break
@@ -507,7 +507,7 b' class HTTPResponse(httplib.HTTPResponse)'
507 507 def readlines(self, sizehint = 0):
508 508 total = 0
509 509 list = []
510 while 1:
510 while True:
511 511 line = self.readline()
512 512 if not line:
513 513 break
@@ -654,7 +654,7 b' def continuity(url):'
654 654
655 655 fo = urllib2.urlopen(url)
656 656 foo = ''
657 while 1:
657 while True:
658 658 f = fo.readline()
659 659 if f:
660 660 foo = foo + f
@@ -1309,7 +1309,7 b' class localrepository(repo.repository):'
1309 1309 b = []
1310 1310 for n in nodes:
1311 1311 t = n
1312 while 1:
1312 while True:
1313 1313 p = self.changelog.parents(n)
1314 1314 if p[1] != nullid or p[0] == nullid:
1315 1315 b.append((t, n, p[0], p[1]))
@@ -1777,7 +1777,7 b' class localrepository(repo.repository):'
1777 1777 pr.total = efiles
1778 1778 source.callback = None
1779 1779
1780 while 1:
1780 while True:
1781 1781 chunkdata = source.filelogheader()
1782 1782 if not chunkdata:
1783 1783 break
@@ -51,7 +51,7 b' class lock(object):'
51 51
52 52 def lock(self):
53 53 timeout = self.timeout
54 while 1:
54 while True:
55 55 try:
56 56 self.trylock()
57 57 return 1
@@ -346,7 +346,7 b' class linereader(object):'
346 346 return self.fp.readline()
347 347
348 348 def __iter__(self):
349 while 1:
349 while True:
350 350 l = self.readline()
351 351 if not l:
352 352 break
@@ -1151,7 +1151,7 b' class revlog(object):'
1151 1151 try:
1152 1152 # loop through our set of deltas
1153 1153 chain = None
1154 while 1:
1154 while True:
1155 1155 chunkdata = bundle.deltachunk(chain)
1156 1156 if not chunkdata:
1157 1157 break
@@ -88,7 +88,7 b' class sshrepository(wireproto.wirereposi'
88 88 break
89 89
90 90 def readerr(self):
91 while 1:
91 while True:
92 92 size = util.fstat(self.pipee).st_size
93 93 if size == 0:
94 94 break
@@ -148,7 +148,7 b' class sshrepository(wireproto.wirereposi'
148 148 r = self._call(cmd, **args)
149 149 if r:
150 150 return '', r
151 while 1:
151 while True:
152 152 d = fp.read(4096)
153 153 if not d:
154 154 break
@@ -193,7 +193,7 b' class sshrepository(wireproto.wirereposi'
193 193 d = self._call("addchangegroup")
194 194 if d:
195 195 self._abort(error.RepoError(_("push refused: %s") % d))
196 while 1:
196 while True:
197 197 d = cg.read(4096)
198 198 if not d:
199 199 break
@@ -29,7 +29,7 b' for filename in sys.argv[1:]:'
29 29
30 30 m = md5()
31 31 try:
32 while 1:
32 while True:
33 33 data = fp.read(8192)
34 34 if not data:
35 35 break
@@ -95,7 +95,7 b' class ProxyHandler (BaseHTTPServer.BaseH'
95 95 iw = [self.connection, soc]
96 96 ow = []
97 97 count = 0
98 while 1:
98 while True:
99 99 count += 1
100 100 (ins, _, exs) = select.select(iw, ow, iw, 3)
101 101 if exs:
General Comments 0
You need to be logged in to leave comments. Login now