コード例 #1
0
ファイル: sublimelint.py プロジェクト: cmorellirv/sublimelint
	def lint(self, view_id):
		view = Linter.get_view(view_id)

		if view is not None:
			print 'SublimeLint: running on `%s`' % os.path.split(view.file_name() or 'untitled')[1]
			code = Linter.text(view)
			thread.start_new_thread(Linter.lint_view, (view_id, code, self.finish))
コード例 #2
0
ファイル: sublimelint.py プロジェクト: cmorellirv/sublimelint
	def on_post_save(self, view):
		# this will reload submodules if they are saved with sublime text
		for name, module in self.modules.modules.items():
			if module.__file__ == view.file_name():
				self.modules.reload(module)
				Linter.reload(name)
				break

		self.hit(view)
コード例 #3
0
ファイル: sublimelint.py プロジェクト: cmorellirv/sublimelint
	def on_new(self, view):
		Linter.assign(view)
		settings = view.settings()
		syntax = settings.get('syntax')
		def on_change():
			if settings.get('syntax') != syntax:
				Linter.assign(view)

		settings.add_on_change('lint-syntax', on_change)
コード例 #4
0
ファイル: python.py プロジェクト: cmorellirv/sublimelint
	def lint(self, code=None):
		self.highlight = Highlight(code)
		self.errors = {}

		if code is None:
			code = Linter.text(self.view)

		if code:
			self.check(code)
コード例 #5
0
def lintthesql(args):
    cwd = os.getcwd()
    config_file = cwd + '/.lintthesql.yml'
    config_file_path = Path(config_file)

    if config_file_path.is_file():
        config = Config(config_file)
    else:
        # doesn't exist
        print('Config file does not exist you dummy!')
        sys.exit()

    linter = Linter(config)
    should_rewrite = args.fix
    input_file = cwd + '/' + args.file
    input_file_path = Path(input_file)

    if input_file_path.is_file():
        try:
            lint_file(linter, input_file)
        except ValueError as error:
            print(error)
    elif input_file_path.is_dir():
        input_files = []

        for root, dirs, files in os.walk(input_file_path):
            path = root.split(os.sep)

            for file in files:
                input_file = root + '/' + file

                if os.path.splitext(input_file)[1] == '.' + args.type.replace(
                        '.', ''):
                    input_files.append(input_file)

        total_input_files = len(input_files)

        for input_file in input_files:
            try:
                lint_file(linter, input_file)
            except ValueError as error:
                print(error)

            input_file_index = input_files.index(input_file)
            progress = (input_file_index + 1) / total_input_files * 100

            if nyan_progress:
                nyan_progress.update(progress)
    else:
        # doesn't exist
        print('Input file does not exist you dummy!')
        sys.exit()
コード例 #6
0
ファイル: sublimelint.py プロジェクト: cmorellirv/sublimelint
		def on_change():
			if settings.get('syntax') != syntax:
				Linter.assign(view)
コード例 #7
0
 def __init__(self):
     Linter.__init__(self)
     self.add_path_filter(in_rts_dir)
     self.add_path_filter(lambda path: path.suffix == '.h')
コード例 #8
0
ファイル: custom_linting.py プロジェクト: Jride/CoconutRunner
from linter import Linter
from lint_rule_final_classes import LintRuleFinalClasses

def emitWarning(file, line, message):
	# Xcode line indexes are 1 based, not 0 based
	print(file + ":" + str(line+1) + ": warning: " + message)
	#echo "/foo/bar/tmp.sh:42: error: This is the error message"

###### MAIN ######

# First argument: Project directory
root = sys.argv[1]

# Second argument: Search path
search_path = sys.argv[2]

for file_path in glob.glob(search_path + '/**/*.swift', recursive = True):

	with open(file_path, 'r') as file:

		linter = Linter()
		linter.add_rule(LintRuleFinalClasses())

		warnings = linter.warnings_for_file(file.read())

		for warning in warnings:
			relative_path = file_path[len(root)+1:]
			emitWarning(relative_path, warning.line, warning.message)

コード例 #9
0
def run_linter(cell):
    code = "\n".join(cell.get('source', []))
    tree = ast.parse(code)
    l = Linter()
    l.visit(tree)
    return [k.msg for k in l.warnings.keys()]
コード例 #10
0
 def makeSUT(self):
     linter = Linter()
     linter.add_rule(LintRuleFinalClasses())
     return linter