-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'laziness' into develop
- Loading branch information
Showing
31 changed files
with
869 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ rvm: | |
- 2.0 | ||
- 2.1 | ||
- 2.2 | ||
|
||
before_script: | ||
- sudo npm install -g coffeelint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
require 'bundler/gem_tasks' | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'test' | ||
t.test_files = FileList['test/**/*_test.rb'] | ||
t.warning = true | ||
end | ||
|
||
task :default => :test |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,5 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'logger' | ||
require 'docopt' | ||
require 'face_control' | ||
require 'stash' | ||
|
||
begin | ||
USAGE = "#{File.dirname(__FILE__)}/../USAGE" | ||
args = Docopt.docopt(File.read(USAGE)) | ||
|
||
project = args['<project>'] | ||
repository = args['<repository>'] | ||
pull_request_id = args['<pull_request_id>'] | ||
|
||
ignored_severities = [] | ||
if args['--skip-severity'] | ||
ignored_severities = args['--skip-severity'].split(',') | ||
puts "Skipping RuboCop offenses with severities: #{ignored_severities.join(', ')}." | ||
end | ||
|
||
config = Stash::Config.new | ||
server = Stash::Server.new(config.host, config.user, config.password, Logger.new(STDOUT)) | ||
repository = server.repository(project, repository) | ||
pull_request = repository.pull_request(pull_request_id) | ||
|
||
[ | ||
FaceControl::Inputs::RubocopJson.new(ignored_severities), | ||
FaceControl::Inputs::CoffeeLintRaw.new | ||
].each do |input| | ||
input.comments.each do |comment| | ||
pull_request.add_comment(comment.file, comment.line, comment.text) | ||
end | ||
end | ||
rescue Docopt::Exit => e | ||
puts e.message | ||
end | ||
FaceControl::CLI.new.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require 'face_control/version' | ||
require 'face_control/cli' | ||
require 'face_control/comment' | ||
require 'face_control/inputs' | ||
require 'face_control/checker_runner' | ||
require 'face_control/checkers' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module FaceControl | ||
class CheckerRunner | ||
def initialize(checker_class, filenames = [], options = {}) | ||
@checker = checker_class.new | ||
if @checker.respond_to?(:options=) | ||
@checker.options = options | ||
end | ||
|
||
@filenames = filenames | ||
end | ||
|
||
def comments | ||
return [] if relevant_filenames.empty? | ||
|
||
@checker.parse(`#{@checker.command(relevant_filenames.join(' '))}`) | ||
end | ||
|
||
private | ||
|
||
def relevant_filenames | ||
@relevant_filenames ||= @checker.relevant_globs.map do |glob| | ||
@filenames.select do |filename| | ||
File.fnmatch?(glob, filename) | ||
end | ||
end.flatten.uniq | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'face_control/checkers/rubocop' | ||
require 'face_control/checkers/coffeelint' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'face_control/comment' | ||
|
||
module FaceControl | ||
module Checkers | ||
class Example | ||
# @optional | ||
# Define only if you use @options in the following methods | ||
attr_writer :options | ||
|
||
# @return [Array<String>] Shell globs to filter only files relevant to this checker | ||
# out of all files with added lines in the pull request | ||
def relevant_globs | ||
%w(bin/*) | ||
end | ||
|
||
# @param filenames [String] Files with added lines in the pull request | ||
# only relevant to this checker (filtered by globs above) | ||
# @return [String] Command line to check the files | ||
def command(filenames) | ||
"ls -l #{filenames}" | ||
end | ||
|
||
# @param command_output [String] Stdout of the command above | ||
# @return Array<FaceControl::Comment> Comments to post to the pull request | ||
def parse(command_output) | ||
command_output.split("\n").map do |line| | ||
fields = line.split | ||
|
||
mode = fields.first | ||
file = fields.last | ||
|
||
if mode != '-rwxr-xr-x' | ||
Comment.new(file: file, line: 1, text: 'Invalid file mode') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'json' | ||
require 'face_control/comment' | ||
|
||
module FaceControl | ||
module Checkers | ||
class CoffeeLint | ||
def relevant_globs | ||
%w(*.coffee) | ||
end | ||
|
||
def command(filenames) | ||
"coffeelint --reporter raw #{filenames}" | ||
end | ||
|
||
def parse(command_output) | ||
JSON.parse(command_output).map do |file, problems| | ||
problems.map do |problem| | ||
Comment.new( | ||
file: file, | ||
line: problem['lineNumber'], | ||
text: "(#{problem['level']}) #{problem['message']}" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.