コード例 #1
0
ファイル: check_tidy.py プロジェクト: zhaixuepan/iotjs
def check_tidy(src_dir):
    count_lines = 0
    count_empty_lines = 0

    for (dirpath, dirnames, filenames) in os.walk(src_dir):
        if any(d in fs.relpath(dirpath, src_dir) for d in skip_dirs):
            continue

        files = [
            fs.join(dirpath, name) for name in filenames
            if is_interesting(name)
        ]

        if not files:
            continue

        for file in files:
            if is_checked_by_clang(file):
                formatted = ex.run_cmd_output(' '.join(
                    ['clang-format-3.8', '-style=file', file]),
                                              quiet=True)
                f = open(file + '.formatted', 'w')
                f.write(formatted)
                f.close()
                ex.check_run_cmd('diff', [file, file + '.formatted'],
                                 quiet=True)
                fs.remove(file + '.formatted')

        for line in fileinput.input(files):
            if '\t' in line:
                report_error('TAB character')
            if '\r' in line:
                report_error('CR character')
            if line.endswith(' \n') or line.endswith('\t\n'):
                report_error('trailing whitespace')
            if not line.endswith('\n'):
                report_error('line ends without NEW LINE character')

            if len(line) - 1 > column_limit:
                report_error('line exceeds %d characters' % column_limit)

            if fileinput.isfirstline():
                if not CheckLicenser.check(fileinput.filename()):
                    report_error_name_line(fileinput.filename(), None,
                                           'incorrect license')

            count_lines += 1
            if not line.strip():
                count_empty_lines += 1

    print "* total lines of code: %d" % count_lines
    print("* total non-blank lines of code: %d" %
          (count_lines - count_empty_lines))
    print "%s* total errors: %d%s" % (TERM_RED if count_err > 0 else
                                      TERM_GREEN, count_err, TERM_EMPTY)
    print

    return count_err == 0
コード例 #2
0
ファイル: check_tidy.py プロジェクト: shanghaife/iotjs
    def check(self, files):
        for line in fileinput.input(files):
            for i, rule in enumerate(self.rules):
                mc = rule.search(line)
                if mc:
                    self.report_error(self.err_msgs[i])

            if fileinput.isfirstline():
                if not CheckLicenser.check(fileinput.filename()):
                    self.report_error('incorrect license')

            self.count_lines += 1
            if not line.strip():
                self.count_empty_lines += 1
コード例 #3
0
ファイル: check_tidy.py プロジェクト: MoonkiHong/iotjs
    def check(self, files):
        for line in fileinput.input(files):
            for i, rule in enumerate(self.rules):
                mc = rule.search(line)
                if mc:
                    self.report_error(self.err_msgs[i])

            if fileinput.isfirstline():
                if not CheckLicenser.check(fileinput.filename()):
                    self.report_error('incorrect license')

            self.count_lines += 1
            if not line.strip():
                self.count_empty_lines += 1
コード例 #4
0
ファイル: check_tidy.py プロジェクト: r21-iot/iotjs
def check_tidy(src_dir):
    count_lines = 0
    count_empty_lines = 0

    for (dirpath, dirnames, filenames) in os.walk(src_dir):
        if any(d in fs.relpath(dirpath, src_dir) for d in skip_dirs):
            continue

        files = [
            fs.join(dirpath, name) for name in filenames
            if is_interesting(name)
        ]

        if not files:
            continue

        for line in fileinput.input(files):
            if '\t' in line:
                report_error('TAB character')
            if '\r' in line:
                report_error('CR character')
            if line.endswith(' \n') or line.endswith('\t\n'):
                report_error('trailing whitespace')
            if not line.endswith('\n'):
                report_error('line ends without NEW LINE character')

            if len(line) - 1 > column_limit:
                report_error('line exceeds %d characters' % column_limit)

            if fileinput.isfirstline():
                if not CheckLicenser.check(fileinput.filename()):
                    report_error_name_line(fileinput.filename(), None,
                                           'incorrent license')

            count_lines += 1
            if not line.strip():
                count_empty_lines += 1

    print "* total lines of code: %d" % count_lines
    print("* total non-blank lines of code: %d" %
          (count_lines - count_empty_lines))
    print "%s* total errors: %d%s" % (TERM_RED if count_err > 0 else
                                      TERM_GREEN, count_err, TERM_EMPTY)
    print

    return count_err == 0
コード例 #5
0
ファイル: check_tidy.py プロジェクト: zhy0313/iotjs
    def check(self, files):
        for line in fileinput.input(files):
            if '\t' in line:
                self.report_error('TAB character')
            if '\r' in line:
                self.report_error('CR character')
            if line.endswith(' \n') or line.endswith('\t\n'):
                self.report_error('trailing whitespace')
            if not line.endswith('\n'):
                self.report_error('line ends without NEW LINE character')

            if len(line) - 1 > StyleChecker.column_limit:
                self.report_error('line exceeds %d characters' %
                                  StyleChecker.column_limit)

            if fileinput.isfirstline():
                if not CheckLicenser.check(fileinput.filename()):
                    self.report_error('incorrect license')

            self.count_lines += 1
            if not line.strip():
                self.count_empty_lines += 1
コード例 #6
0
ファイル: check_tidy.py プロジェクト: LaszloLango/iotjs
    def check(self, files):
        for line in fileinput.input(files):
            if '\t' in line:
                self.report_error('TAB character')
            if '\r' in line:
                self.report_error('CR character')
            if line.endswith(' \n') or line.endswith('\t\n'):
                self.report_error('trailing whitespace')
            if not line.endswith('\n'):
                self.report_error('line ends without NEW LINE character')

            if len(line) - 1 > StyleChecker.column_limit:
                self.report_error('line exceeds %d characters'
                                  % StyleChecker.column_limit)

            if fileinput.isfirstline():
                if not CheckLicenser.check(fileinput.filename()):
                    self.report_error('incorrect license')


            self.count_lines += 1
            if not line.strip():
                self.count_empty_lines += 1