#!/usr/bin/env python3 # A linter to warn for ASSERT macros which are separated from their argument # list by a space, which Clang's CPP barfs on from pathlib import Path from linter import run_linters, RegexpLinter linters = [ RegexpLinter(r'WARN\s+\(', message='CPP macros should not have a space between the macro name and their argument list'), RegexpLinter(r'ASSERT\s+\(', message='CPP macros should not have a space between the macro name and their argument list'), RegexpLinter(r'ASSERT2\s+\(', message='CPP macros should not have a space between the macro name and their argument list'), RegexpLinter(r'#ifdef\s+', message='`#if defined(x)` is preferred to `#ifdef x`'), RegexpLinter(r'#if\s+defined\s+', message='`#if defined(x)` is preferred to `#if defined x`'), RegexpLinter(r'#ifndef\s+', message='`#if !defined(x)` is preferred to `#ifndef x`'), ] for l in linters: # Need do document rules! l.add_path_filter(lambda path: path != Path('docs', 'coding-style.html')) # Don't lint vendored code l.add_path_filter(lambda path: not path.name == 'config.guess') # Don't lint font files l.add_path_filter(lambda path: not path.parent == Path('docs','users_guide', 'rtd-theme', 'static', 'fonts'))
#!/usr/bin/env python3 """ Linters for testsuite makefiles """ from linter import run_linters, RegexpLinter """ Warn for use of `--interactive` inside Makefiles (#11468). Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ interactive_linter = \ RegexpLinter(r'--interactive', message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." ).add_path_filter(lambda path: path.name == 'Makefile') test_hc_quotes_linter = \ RegexpLinter('\t\\$\\(TEST_HC\\)', message = "Warning: $(TEST_HC) should be quoted in Makefiles.", ).add_path_filter(lambda path: path.name == 'Makefile') ghc_pkg_quotes_linter = \ RegexpLinter('\t\\$\\(GHC_PKG\\)', message = "Warning: $(GHC_PKG) should be quoted in Makefiles.", ).add_path_filter(lambda path: path.name == 'Makefile') haddock_quotes_linter = \ RegexpLinter('\t\\$\\(HADDOCK\\)', message = "Warning: $(HADDOCK) should be quoted in Makefiles.",
#!/usr/bin/env python3 """ Warn for use of `--interactive` inside Makefiles (#11468). Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ from linter import run_linters, RegexpLinter linters = [ RegexpLinter( r'--interactive', message= "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." ).add_path_filter(lambda path: path.name == 'Makefile') ] if __name__ == '__main__': run_linters(linters, subdir='testsuite')
#!/usr/bin/env python3 """ Warn for use of `--interactive` inside Makefiles (#11468). Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to forget one of those flags when adding a new test. """ from linter import run_linters, RegexpLinter linters = [ RegexpLinter( r'--interactive', message= "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`." ) ] if __name__ == '__main__': run_linters(linters) #$, subdir='testsuite')