blob: 3d4da4be727244ec9264941464f00ba3d8d2bb3a [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import os
import re
import subprocess
import sys
SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
SKY_ROOT = os.path.dirname(SKY_TOOLS_DIR)
SRC_ROOT = os.path.dirname(SKY_ROOT)
WORKBENCH = os.path.join(SRC_ROOT, 'sky', 'packages', 'workbench')
DART_SDK = os.path.join(SRC_ROOT, 'third_party', 'dart-sdk', 'dart-sdk', 'bin')
DARTANALYZER = os.path.join(DART_SDK, 'dartanalyzer')
# Ignored because they're not indicative of specific errors.
re.compile(r'^Analyzing \['),
re.compile(r'^No issues found'),
re.compile(r'^[0-9]+ errors? and [0-9]+ warnings? found.'),
re.compile(r'^([0-9]+|No) (error|warning|issue)s? found.'),
# Ignore analyzer status output.
re.compile(r'^[0-9]+ errors(, [0-9]+ warnings)? and [0-9]+ hints found.'),
# Ignored because they don't affect Sky code
re.compile(r'\[hint\] When compiled to JS, this test might return true when the left hand side is an int'),
# TODO: Remove once sdk-extensions are in place
re.compile(r'^\[error\] Native functions can only be declared in'),
# TODO: Fix all the warnings in the mojo packages
# TODO: Remove this once Sky no longer generates this warning.
re.compile(r'.*cannot both be unnamed'),
# TODO: Remove this once Sky no longer generates this warning.
re.compile(r'^\[warning] Missing concrete implementation of \'RenderObject.toString\''),
def main():
parser = argparse.ArgumentParser(description='Sky Analyzer')
parser.add_argument('--congratulate', action="store_true")
parser.add_argument('app_path', type=str)
args = parser.parse_args()
DARTANALYZER, "--package-warnings", args.app_path,
"--package-root", os.path.join(WORKBENCH, "packages"),
], stderr=subprocess.STDOUT, cwd=WORKBENCH)
except subprocess.CalledProcessError as e:
errors = [l for l in e.output.split('\n')
if not any(p.match(l) for p in _IGNORED_PATTERNS)]
if len(errors) > 0:
for error in errors:
print >> sys.stderr, error
# Propagate analyzer error code.
return e.returncode
# If we do not have any errors left after filtering, return 0.
if args.congratulate:
print >> sys.stdout, "No analyzer warnings!"
return 0
if __name__ == '__main__':