Commit Graph

158 Commits

Author SHA1 Message Date
Martin Geisler
11500eaa6f check-code: better check for overwriting $HGRCPATH
Suggested by Mads Kiilerich on IRC.
2011-03-02 14:22:50 +01:00
Martin Geisler
83c27fb95f tests: don't overwrite HGRCPATH
Overwriting instead of appending to the file removes the [defaults]
section put into the file by run-tests.py.

It also defeats the --inotify option to run-tests.py.

(Nothing was broken yet, but the lack of -d "0 0" cause changeset
hashes to change unexpectedly in a test case I was editing.)
2011-03-01 17:01:17 +01:00
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
Martin Geisler
77e1343f88 check-code: do not complain about 'ls x | foo -v'
Such a line was introduced in test-subrepo-git.t in 686775e575f3,
which made check-code confused.
2011-01-26 12:35:02 +01:00
Matt Mackall
940fa28a3f check-code: catch os.path.relpath 2010-12-16 14:50:37 -06:00
Matt Mackall
cdcb8c0f47 check-code: catch "except as" 2010-12-16 14:50:36 -06:00
Thomas Arendsen Hein
3669dce8b1 check-code: single check for Python keywords used as a function
This replaces the specific checks for del/and/or/not/except and additionally
checks other Python keywords.
2010-12-03 12:04:31 +01:00
Thomas Arendsen Hein
31218f1044 check-code: check for gratuitous whitespace after Python keywords 2010-12-03 11:23:38 +01:00
Martin Geisler
6a3d9310ab code style: prefer 'is' and 'is not' tests with singletons 2010-11-22 18:15:58 +01:00
Adrian Buehlmann
5e2e71ea82 check-code: catch Python 'is' comparing number or string literals
The Python 'is' operator compares object identity, so it should
definitely not be applied to string or number literals, which Python
implementations are free to represent with a temporary object.

This should catch the following kinds of bogus expressions (examples):

  x is 'foo'     x is not 'foo'
  x is "bar"     x is not "bar"
  x is 42        x is not 42
  x is -36       x is not -36

As originally proposed by Martin Geisler, amended with catching
negative numbers.
2010-11-21 11:52:27 +01:00
Martin Geisler
ca016e40cb check-code: catch 'ls filename --option' case as per 8745def6e53b 2010-11-17 09:37:57 +01:00
Martin Geisler
9d82b9ed1f check-code: using and/or/not as a function is bad style 2010-11-11 00:08:09 +01:00
Matt Mackall
0f064b0796 check-code: warning and fixes for whitespace in unified tests 2010-10-20 14:57:36 -05:00
Martin Geisler
77ce66fb6a check-code: find trailing whitespace 2010-10-20 10:13:04 +02:00
Adrian Buehlmann
758fc721d8 check-code: add 'no tab indent' check for unified tests
and fix the offending tests accordingly
2010-10-16 18:09:01 +02:00
Dan Villiom Podlaski Christiansen
8e99053714 tests: compatibility fix.
'touch -d *' doesn't work on Mac OS X. In order to prevent this from
occuring again, a check for the case is added to 'check-code.py'.
2010-09-21 18:36:23 +02:00
Matt Mackall
5d9fc42983 tests: drop a bunch of sed calls from unified tests 2010-09-21 16:44:13 -05:00
Matt Mackall
0c59a109d6 check-code: add some basic support for unified tests 2010-09-21 12:41:24 -05:00
Martin Geisler
ec0bf03276 Merge with stable 2010-08-15 18:13:46 +02:00
Martin Geisler
888421d8ca check-code: catch "echo -n" in tests 2010-08-15 17:48:05 +02:00
Alecs King
00c728120d check-code: add exit status
so that we can use it in a shell command combination and/or in hg hooks.
2010-08-12 16:42:41 +08:00
Renato Cunha
f65cf06e03 check-code: added a check for calls to the builtin cmp function 2010-08-07 16:13:53 -03:00
Matt Mackall
661034417e check-code: add warning on lines over 80 characters 2010-07-25 17:10:32 -05:00
Martin Geisler
71971a8928 check-code: warn about untranslated ui.warn calls 2010-07-16 14:40:57 +02:00
Matt Mackall
6c780d7b4f check-code: add --blame switch 2010-07-16 13:26:39 -05:00
Martin Geisler
12085cad2b check-code: catch dict.has_key 2010-07-16 14:48:52 +02:00
Martin Geisler
f985c9d777 Merge with stable 2010-07-16 14:45:52 +02:00
Renato Cunha
29ee0d7c07 check-code: added check for reduce usage 2010-07-14 23:15:03 -03:00
Renato Cunha
f678753e0c check-code: check for tuple parameter unpacking (missing in py3k) 2010-07-14 23:15:00 -03:00
Martin Geisler
59385f10e8 check-code: add test for callable 2010-07-09 14:01:55 +02:00
Martin Geisler
5bd48f2f1e check-code: reformat long lines 2010-06-15 10:01:55 +02:00
Martin Geisler
28297c8184 check-code: catch format(), introduced in Python 2.6 2010-06-15 09:55:59 +02:00
Martin Geisler
5d9db0b74d check-code: fix check for any/all function
The old check would only detect any/all at the beginning of a line.
The regexp was probably just modeled after the preceding regexp which
(correctly) finds the 'with' keyword at the beginning of a line.

We now complain about 'any(' and 'all(' anywhere in a line, unless it
is preceded by 'def'. This allows us to define our own compatibility
wrapper in util and use 'util.any(' in the code.
2010-06-15 09:51:52 +02:00
Yuya Nishihara
ffeee8dfd0 check-code: add check for 'source' 2010-05-21 22:53:57 +09:00
Nicolas Dumazet
7f1a963829 pylint, pyflakes: remove unused or duplicate imports 2010-04-14 17:58:10 +09:00
Matt Mackall
062bdb8d0b check-code: add a warnings level
- demote "unwrapped ui message"
2010-04-12 17:41:32 -07:00
Matt Mackall
0726edad79 Merge with stable 2010-04-01 17:51:59 -05:00
Mads Kiilerich
6f24bc8f03 check-code.py: Check for bare ^
Solaris sh interprets ^ as some kind of piping symbol.
2010-03-31 11:07:46 +02:00
Benoit Boissinot
2fa74b1aa8 check-code: more tests and more robust python filtering 2010-03-18 16:32:03 +01:00
Matt Mackall
9ead8ddeec check-code: fix check-code complaint 2010-03-17 15:36:48 -05:00
Benoit Boissinot
4e213c5898 check-code: improve quote detection regexp, add tests 2010-03-17 14:15:33 +01:00
Pierre-Yves David
ada28ea37e check-code: add a return value to checkfile function
The checkfile function returns True if the file is correct, False
otherwise.
2010-03-17 10:51:26 +01:00
Pierre-Yves David
d5796f6daf code-code: Add a logfunc argument to checkfile
This helps external tool customisation. The logfunc argument must be a
function called to report errors. A new logger class is also added to
keep the old behaviour by default.
2010-03-16 19:53:00 +01:00
Pierre-Yves David
ffbf49397a check-code: Add a `maxerr argument to the checkfile` function
check-code.py used to halt after 15 errors. This changeset adds a new
argument to the checkfile function to control this limit.
2010-03-16 19:52:58 +01:00
Pierre-Yves David
16e40846e1 check-code: Add a `checkfile` function
The part of the code actually checking each file is moved in the
``checkfile`` function to allow external reuses.
2010-03-16 19:52:57 +01:00
Pierre-Yves David
64bcf4a5c3 check-code: Only call check-code if __name__ = "__main__".
This changeset moves the code that actually executes something to the
"if __name__ = '__main__'" section to allow the file to be imported as
a module.
2010-03-16 19:52:56 +01:00
Benoit Boissinot
57712fa835 check-code: remove simple quotes first 2010-03-16 16:39:17 +01:00
Matt Mackall
36aa3dd390 check-code: add check for any/all 2010-03-12 16:16:47 -06:00
Mads Kiilerich
badb17240e test-merge-default and check-code.py: No "export x=x" in sh 2010-03-08 03:07:35 +01:00
Matt Mackall
0bc7a87925 check-code: two more rules
- no plain Exceptions
- complain about unmarked ui messages
2010-02-13 23:20:17 -06:00
Matt Mackall
a17b73e2eb check-code: import some pylint checks 2010-02-09 13:53:24 -06:00
Martin Geisler
4817fcfe96 check-code.py: make help strings consistent 2010-02-07 10:58:51 +01:00
Mads Kiilerich
289637cadf check-code.py: escape backslash 2010-02-07 01:52:10 +01:00
Matt Mackall
1a71a75d3d check-code: del isn't a function 2010-01-28 22:44:54 -06:00
Matt Mackall
f7b37826db check-code: fix copyright date 2010-01-28 22:44:45 -06:00
Matt Mackall
6c94f28bab check-code: add some ignore hints 2010-01-28 22:44:18 -06:00
Matt Mackall
3f5075a48f check-code: check thyself 2010-01-25 01:23:34 -06:00
Matt Mackall
9b0512d1f6 Introduce check-code.py
check-code is a simple regex-based framework for checking our code and
tests for common style and portability errors. Currently, it knows a
fair amount about our Python and C style, and a little about common
shell script portability problems.
2010-01-25 00:05:22 -06:00