Exemplo n.º 1
0
	def run(self, edit):
		#settings = self.view.settings()
		js_code = self.view.substr(sublime.Region(0, self.view.size()))

		file_data = None
		try:
			file_data = fileparser.get_file_data_from_content("sublime cleanjs", js_code)
		except Exception as error:
			self.show_messages_to_panel(str(error), PANEL_KEY)
			return

		result = reviewer.review(file_data, working_dir=sublime.packages_path() + os.sep + "cleanjs")

		text = self.get_full_report_from_result(result)

		self.show_messages_to_panel(text, PANEL_KEY)
		self.show_messages_to_regions(result.message_bag.get_messages(), file_data.lines)
Exemplo n.º 2
0
			// Just simply return the field
			return this.someField; // And some inline comment
		},

		somethingTODOfunction: function() {}
	};
	"""

    # Tricking the PYTHONPATH because relative imports don't work when running the file standalone
    import sys
    sys.path.append("./")
    sys.path.append("../")

    # Creating the reviewer instance, giving it the parsed file
    from parsers import fileparser
    file_data = fileparser.get_file_data_from_content("test_file",
                                                      file_content)
    from reviewers import messagebag
    message_bag = messagebag.MessageBag()
    reviewer = Reviewer()

    # Checking that 2 TODOFIXMES are found
    reviewer.review_todos_and_fixmes(file_data, message_bag)
    assert len(message_bag.get_messages()) == 2, 1
    assert message_bag.get_messages()[0].line == 10, 2
    assert message_bag.get_messages()[1].line == 24, 3
    message_bag.reset_messages()

    # Checking the fucntion stats
    reviewer.review_min_max_function_length(file_data.functions, message_bag)
    assert message_bag.messages[
        0].content == "Longest function is 8 lines long, and shortest one is 0 (average is 3)", 4
Exemplo n.º 3
0
			// Just simply return the field
			return this.someField; // And some inline comment
		},

		somethingTODOfunction: function() {}
	};
	"""
	
	# Tricking the PYTHONPATH because relative imports don't work when running the file standalone
	import sys
	sys.path.append("./")
	sys.path.append("../")
	
	# Creating the reviewer instance, giving it the parsed file
	from parsers import fileparser
	file_data = fileparser.get_file_data_from_content("test_file", file_content)
	from reviewers import messagebag
	message_bag = messagebag.MessageBag()
	reviewer = Reviewer()
	
	# Checking that 2 TODOFIXMES are found
	reviewer.review_todos_and_fixmes(file_data, message_bag)
	assert len(message_bag.get_messages()) == 2, 1
	assert message_bag.get_messages()[0].line == 10, 2
	assert message_bag.get_messages()[1].line == 24, 3
	message_bag.reset_messages()
	
	# Checking the fucntion stats
	reviewer.review_min_max_function_length(file_data.functions, message_bag)
	assert message_bag.messages[0].content == "Longest function is 8 lines long, and shortest one is 0 (average is 3)", 4