Commit 9f5b11fa authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan Committed by Marge Bot

Remove arc scripts

parent 76ac103f
Subproject commit 957f9e4e8eb422dcb72f02f07767a1ed5969baab
#!/usr/bin/env python3
# A linter to warn when binary files are added to the repository
import sys
import os
import json
path = sys.argv[1]
warnings = []
if os.path.isfile(path):
with open(path, 'rb') as f:
if b'\0' in f.read(8000):
warning = {
'severity': 'warning',
'message': 'This file appears to be a binary file; does it really belong in the repository?'
}
warnings.append(warning)
print(json.dumps(warnings))
#!/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
import sys
import logging
import os
import re
import json
def setup_logging(logger):
"""
``arc lint`` makes it quite tricky to catch debug output from linters.
Log to a file to work around this.
"""
hdlr = logging.FileHandler('linter.log', 'w')
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
return logger
logger = logging.getLogger()
#setup_logging(logger)
logger.debug(sys.argv)
def add_warning(severity, message, line):
entry = {
'severity': severity,
'message': message,
'line': line
}
warnings.append(entry)
class Linter(object):
def __init__(self):
self.warnings = []
def add_warning(self, **entry):
self.warnings.append(entry)
def lint(self, path):
pass
class LineLinter(Linter):
def lint(self, path):
if os.path.isfile(path):
with open(path, 'rb') as f:
for lineno, line in enumerate(f):
self.lint_line(lineno+1, line)
def lint_line(self, lineno, line):
pass
class RegexpLinter(LineLinter):
def __init__(self, regex, **warning):
LineLinter.__init__(self)
self.re = re.compile(regex)
self.warning = warning
def lint_line(self, lineno, line):
if self.re.search(line):
warning = {
'line': lineno,
}
warning.update(self.warning)
self.add_warning(**warning)
linters = [
RegexpLinter(br'ASSERT\s+\(',
message='CPP macros should not have a space between the macro name and their argument list'),
RegexpLinter(br'#ifdef\s+',
message='`#if defined(x)` is preferred to `#ifdef x`',
severity='warning'),
RegexpLinter(br'#if\s+defined\s+',
message='`#if defined(x)` is preferred to `#if defined x`',
severity='warning'),
RegexpLinter(br'#ifndef\s+',
message='`#if !defined(x)` is preferred to `#ifndef x`',
severity='warning'),
]
if __name__ == '__main__':
path = sys.argv[1]
for linter in linters:
linter.lint(path)
warnings = [warning
for linter in linters
for warning in linter.warnings]
logger.debug(warnings)
print(json.dumps(warnings))
#!/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.
import sys
import os
import json
import re
path = sys.argv[1]
warnings = []
if os.path.isfile(path):
with open(path) as f:
for lineno, line in enumerate(f):
if '--interactive' in line:
warning = {
'severity': 'warning',
'message': 'Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`',
'line': lineno+1,
}
warnings.append(warning)
print(json.dumps(warnings))
{
"project.name" : "ghc",
"repository.callsign" : "GHC",
"phabricator.uri" : "https://phabricator.haskell.org",
"base" : "git:merge-base(origin/master), arc:prompt",
"load": [
".arc-linters/arcanist-external-json-linter"
]
}
{
"linters": {
"filename": {
"type": "filename"
},
"generated": {
"type": "generated"
},
"merge-conflict": {
"type": "merge-conflict",
"exclude": "(\\.rst$)"
},
"nolint": {
"type": "nolint"
},
"haskell": {
"type": "text",
"include": ["(\\.(l?hs(-boot)?|x|y\\.pp)(\\.in)?$)"],
"severity": {
"5": "disabled",
"2": "warning"
}
},
"c": {
"type": "text",
"include": ["(\\.(c|h)(\\.in)?$)"],
"severity": {
"2": "warning"
}
},
"text-xml": {
"type": "text",
"include": "(\\.xml$)",
"severity": {
"5": "disabled",
"3": "disabled",
"2": "warning"
}
},
"shell": {
"type": "text",
"include": [ "(\\.sh$)" ],
"text.max-line-length": 200,
"severity": {
"2": "warning"
}
},
"makefiles": {
"type": "text",
"include": [ "(Makefile$)", "(\\.mk$)" ],
"text.max-line-length": 400,
"severity": {
"2": "disabled"
}
},
"cabal": {
"type": "text",
"include": ["(\\.cabal(\\.in)?$)"],
"severity": {
"5": "disabled",
"2": "warning"
}
},
"other-text": {
"type": "text",
"include": ["(.travis.yml?)", "(.md$)", "(.txt$)"],
"severity": {
"5": "disabled",
"2": "warning"
}
},
"check-binaries": {
"type": "external-json",
"external-json.script": "python3 .arc-linters/check-binaries.py"
},
"check-makefiles": {
"type": "external-json",
"include": ["(Makefile$)"],
"external-json.script": "python3 .arc-linters/check-makefiles.py"
},
"bad-assert-clang-cpp": {
"type": "external-json",
"include": ["(\\.(l?hs|x|y\\.pp)(\\.in)?$)", "(\\.(c|h)$)"],
"external-json.script": "python3 .arc-linters/check-cpp.py"
}
},
"exclude":
[ "(^libffi-tarballs)",
"(^libraries/binary)",
"(^libraries/bytestring)",
"(^libraries/Cabal)",
"(^libraries/containers)",
"(^libraries/haskeline)",
"(^libraries/pretty)",
"(^libraries/terminfo)",
"(^libraries/transformers)",
"(^libraries/xhtml)",
"(^libraries/Win32)",
"(^libraries/primitive)",
"(^libraries/vector)",
"(^libraries/time)",
"(^libraries/random)",
"(^libraries/array)",
"(^libraries/deepseq)",
"(^libraries/directory)",
"(^libraries/filepath)",
"(^libraries/haskell98)",
"(^libraries/haskell2010)",
"(^libraries/hoopl)",
"(^libraries/hpc)",
"(^libraries/old-locale)",
"(^libraries/old-time)",
"(^libraries/process)",
"(^libraries/unix)",
"(^libraries/parallel)",
"(^libraries/stm)",
"(^libraries/dph)",
"(^utils/haddock)",
"(^nofib)",
"(^utils/hsc2hs)",
"(^libffi-tarballs)",
"(^ghc-tarballs)"
]
}
......@@ -107,6 +107,3 @@
[submodule "gmp-tarballs"]
path = libraries/integer-gmp/gmp/gmp-tarballs
url = ../gmp-tarballs.git
[submodule ".arc-linters/arcanist-external-json-linter"]
path = .arc-linters/arcanist-external-json-linter
url = ../arcanist-external-json-linter.git
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment