permpress 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.rubocop.yml +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/bin/permpress +5 -0
- data/lib/permpress.rb +2 -0
- data/lib/permpress/checkstyle.rb +26 -0
- data/lib/permpress/checkstyle/checkstyle_logger-all.jar +0 -0
- data/lib/permpress/checkstyle/sun_checks.xml +177 -0
- data/lib/permpress/cli.rb +43 -0
- data/lib/permpress/coffeelint.rb +27 -0
- data/lib/permpress/coffeelint/lintci.coffee +12 -0
- data/lib/permpress/command.rb +42 -0
- data/lib/permpress/csslint.rb +63 -0
- data/lib/permpress/golint.rb +12 -0
- data/lib/permpress/govet.rb +7 -0
- data/lib/permpress/jshint.rb +23 -0
- data/lib/permpress/jshint/formatter.js +23 -0
- data/lib/permpress/jslint.rb +7 -0
- data/lib/permpress/jsonlint.rb +19 -0
- data/lib/permpress/rubocop.rb +28 -0
- data/lib/permpress/rubocop/formatter.rb +22 -0
- data/lib/permpress/scsslint.rb +24 -0
- data/lib/permpress/scsslint/scsslint +37 -0
- data/lib/permpress/version.rb +4 -0
- data/permpress.gemspec +27 -0
- data/spec/fixtures/Good.java +6 -0
- data/spec/fixtures/bad.coffee +1 -0
- data/spec/fixtures/bad.css +4 -0
- data/spec/fixtures/bad.go +7 -0
- data/spec/fixtures/bad.java +3 -0
- data/spec/fixtures/bad.js +3 -0
- data/spec/fixtures/bad.json +4 -0
- data/spec/fixtures/bad.rb +4 -0
- data/spec/fixtures/bad.scss +3 -0
- data/spec/fixtures/good.coffee +1 -0
- data/spec/fixtures/good.css +3 -0
- data/spec/fixtures/good.go +7 -0
- data/spec/fixtures/good.js +5 -0
- data/spec/fixtures/good.json +4 -0
- data/spec/fixtures/good.rb +5 -0
- data/spec/fixtures/good.scss +3 -0
- data/spec/fixtures/lint.txt +1 -0
- data/spec/permpress/checkstyle_spec.rb +66 -0
- data/spec/permpress/coffeelint_spec.rb +64 -0
- data/spec/permpress/command_spec.rb +37 -0
- data/spec/permpress/csslint_spec.rb +65 -0
- data/spec/permpress/golint_spec.rb +43 -0
- data/spec/permpress/jshint_spec.rb +65 -0
- data/spec/permpress/jsonlint_spec.rb +45 -0
- data/spec/permpress/rubocop_spec.rb +67 -0
- data/spec/permpress/scsslint_spec.rb +62 -0
- data/spec/permpress_spec.rb +7 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/exit_matcher.rb +15 -0
- data/spec/support/observed_output_context.rb +10 -0
- metadata +204 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'shellwords'
|
3
|
+
|
4
|
+
module Permpress
|
5
|
+
# Generic command interface to execute a command with it's arguments, pipe the output, and exit correctly.
|
6
|
+
class Command
|
7
|
+
attr_reader :executable, :files, :options
|
8
|
+
|
9
|
+
def initialize(executable, files, options = [])
|
10
|
+
@executable = executable
|
11
|
+
@files = files
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(io = $stdout)
|
16
|
+
Bundler.with_clean_env do
|
17
|
+
Open3.popen3(command) do |_, stdout, _, thread|
|
18
|
+
stdout.each do |line|
|
19
|
+
io.puts line
|
20
|
+
end
|
21
|
+
|
22
|
+
exit thread.value.exitstatus
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def command
|
28
|
+
"#{executable} #{flags} #{arguments} 2>&1"
|
29
|
+
end
|
30
|
+
alias_method :to_s, :command
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def flags
|
35
|
+
Shellwords.join(options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def arguments
|
39
|
+
Shellwords.join(files)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'command'
|
3
|
+
|
4
|
+
module Permpress
|
5
|
+
# CSS Lint subcommand. Calls CSS Lint with the correct arguments.
|
6
|
+
class CSSLint < Thor
|
7
|
+
desc 'lint [FILES]', 'Runs linter'
|
8
|
+
method_option :config, banner: 'CONFIG_FILE'
|
9
|
+
|
10
|
+
def lint(*files)
|
11
|
+
Command.new('csslint', files, flags).run
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def flags
|
17
|
+
[
|
18
|
+
"--errors=#{RULES}",
|
19
|
+
'--format=compact'
|
20
|
+
].tap do |flags|
|
21
|
+
flags.concat(["--config=#{options[:config]}"]) if options[:config]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
RULES = %w(
|
26
|
+
important
|
27
|
+
adjoining-classes
|
28
|
+
known-properties
|
29
|
+
box-sizing
|
30
|
+
box-model
|
31
|
+
overqualified-elements
|
32
|
+
display-property-grouping
|
33
|
+
bulletproof-font-face
|
34
|
+
compatible-vendor-prefixes
|
35
|
+
regex-selectors
|
36
|
+
errors
|
37
|
+
duplicate-background-images
|
38
|
+
duplicate-properties
|
39
|
+
empty-rules
|
40
|
+
selector-max-approaching
|
41
|
+
gradients
|
42
|
+
fallback-colors
|
43
|
+
font-sizes
|
44
|
+
font-faces
|
45
|
+
floats
|
46
|
+
star-property-hack
|
47
|
+
outline-none
|
48
|
+
import
|
49
|
+
ids
|
50
|
+
underscore-property-hack
|
51
|
+
rules-count
|
52
|
+
qualified-headings
|
53
|
+
selector-max
|
54
|
+
shorthand
|
55
|
+
text-indent
|
56
|
+
unique-headings
|
57
|
+
universal-selector
|
58
|
+
unqualified-attributes
|
59
|
+
vendor-prefix
|
60
|
+
zero-units
|
61
|
+
).join(',')
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'command'
|
3
|
+
|
4
|
+
module Permpress
|
5
|
+
class JSHint < Thor
|
6
|
+
FORMATTER_PATH = File.expand_path('../jshint/formatter.js', __FILE__)
|
7
|
+
|
8
|
+
desc 'lint [FILES]', 'Runs linter'
|
9
|
+
method_option :config, banner: 'CONFIG_FILE'
|
10
|
+
|
11
|
+
def lint(*files)
|
12
|
+
Command.new('jshint', files, flags).run
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def flags
|
18
|
+
['--reporter', FORMATTER_PATH].tap do |flags|
|
19
|
+
flags.concat(['--config', options[:config]]) if options[:config]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module.exports = {
|
3
|
+
reporter: function (results, data, opts) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
results.forEach(function (result) {
|
7
|
+
var file = result.file,
|
8
|
+
error = result.error,
|
9
|
+
line = error.line,
|
10
|
+
column = error.character,
|
11
|
+
rule = error.code,
|
12
|
+
severity = rule[0] === 'E' ? 'error' : 'warning',
|
13
|
+
message = error.reason;
|
14
|
+
|
15
|
+
console.log(file + ':' +
|
16
|
+
line + ':' +
|
17
|
+
column + '::' +
|
18
|
+
rule + ':' +
|
19
|
+
severity + ':' +
|
20
|
+
message);
|
21
|
+
});
|
22
|
+
}
|
23
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'command'
|
3
|
+
|
4
|
+
module Permpress
|
5
|
+
# JSON Lint subcommand. Calls durable-json-lint with correct arguments.
|
6
|
+
class JSONLint < Thor
|
7
|
+
desc 'lint [FILES]', 'Runs linter'
|
8
|
+
|
9
|
+
def lint(*files)
|
10
|
+
Command.new('durable-json-lint', files, flags).run
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def flags
|
16
|
+
['--format', '{{file}}:{{line}}:{{column}}:::error:{{{description}}}']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'command'
|
3
|
+
|
4
|
+
module Permpress
|
5
|
+
# Rubocop subcommand. Calls Rubocop with correct arguments.
|
6
|
+
class RuboCop < Thor
|
7
|
+
FORMATTER_PATH = File.expand_path('../rubocop/formatter.rb', __FILE__)
|
8
|
+
|
9
|
+
desc 'lint [FILES]', 'Runs linter'
|
10
|
+
method_option :config, banner: 'CONFIG_FILE'
|
11
|
+
|
12
|
+
def lint(*files)
|
13
|
+
Command.new('rubocop', files, flags).run
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def flags
|
19
|
+
[
|
20
|
+
'--require', FORMATTER_PATH,
|
21
|
+
'--format', 'Permpress::Rubocop::Formatter',
|
22
|
+
'--no-color'
|
23
|
+
].tap do |flags|
|
24
|
+
flags.concat(['--config', options[:config]]) if options[:config]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Permpress
|
2
|
+
class Rubocop
|
3
|
+
# Formats Rubocop output for LintCI
|
4
|
+
class Formatter < ::RuboCop::Formatter::BaseFormatter
|
5
|
+
LINE_FORMAT = "%s:%d:%d:%d:%s:%s:%s\n"
|
6
|
+
|
7
|
+
def file_finished(file, offenses)
|
8
|
+
offenses.each do |offense|
|
9
|
+
line = offense.line
|
10
|
+
column = offense.real_column
|
11
|
+
length = offense.location.length
|
12
|
+
|
13
|
+
rule = offense.cop_name
|
14
|
+
severity = offense.severity.name
|
15
|
+
message = offense.message
|
16
|
+
|
17
|
+
output.printf(LINE_FORMAT, file, line, column, length, rule, severity, message)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'command'
|
3
|
+
|
4
|
+
module Permpress
|
5
|
+
# SCSS Lint subcommand. Calls SCSS Lint with the correct arguments.
|
6
|
+
class SCSSLint < Thor
|
7
|
+
desc 'lint [FILES]', 'Runs linter'
|
8
|
+
method_option :config, banner: 'CONFIG_FILE'
|
9
|
+
|
10
|
+
PROGRAM = File.expand_path('../scsslint/scsslint', __FILE__)
|
11
|
+
|
12
|
+
def lint(*files)
|
13
|
+
Command.new(PROGRAM, files, flags).run
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def flags
|
19
|
+
['--format=LintCI'].tap do |flags|
|
20
|
+
flags.concat(["--config=#{options[:config]}"]) if options[:config]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'scss_lint'
|
4
|
+
require 'scss_lint/cli'
|
5
|
+
|
6
|
+
module SCSSLint
|
7
|
+
class Reporter
|
8
|
+
# Formats SCSS Lint output for LintCI
|
9
|
+
class LintCIReporter < Reporter
|
10
|
+
LINE_FORMAT = "%s:%d:%d:%d:%s:%s:%s\n"
|
11
|
+
|
12
|
+
def report_lints
|
13
|
+
return unless lints.any?
|
14
|
+
|
15
|
+
lints.map{|lint| LINE_FORMAT % variables(lint)}.join('')
|
16
|
+
end
|
17
|
+
|
18
|
+
def variables(lint)
|
19
|
+
file = lint.filename
|
20
|
+
line = lint.location.line
|
21
|
+
column = lint.location.column
|
22
|
+
length = lint.location.length
|
23
|
+
|
24
|
+
rule = lint.linter ? lint.linter.name : ''
|
25
|
+
severity = lint.severity.to_s
|
26
|
+
message = lint.description
|
27
|
+
|
28
|
+
[file, line, column, length, rule, severity, message]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
SCSSLint::CLI.new(ARGV).tap do |cli|
|
35
|
+
cli.parse_arguments
|
36
|
+
cli.run
|
37
|
+
end
|
data/permpress.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'permpress/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'permpress'
|
8
|
+
spec.version = Permpress::VERSION
|
9
|
+
spec.authors = ['Allen Madsen']
|
10
|
+
spec.email = ['blatyo@gmail.com']
|
11
|
+
spec.summary = 'Standardizes execution of various linters.'
|
12
|
+
spec.description = 'Standardizes execution of various linters.'
|
13
|
+
spec.homepage = 'https://github.com/lintci/permpress'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\u0000")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'thor'
|
22
|
+
spec.add_runtime_dependency 'bundler'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'pry-byebug'
|
27
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
class xMen
|
@@ -0,0 +1 @@
|
|
1
|
+
class XMen
|