Fix: #4219: Add CodeClimate Platform.
This commit is contained in:
parent
2a4aa0fdb1
commit
b6de905ee4
|
@ -0,0 +1,46 @@
|
|||
engines:
|
||||
rubocop:
|
||||
enabled: true
|
||||
checks:
|
||||
Rubocop/Style/SpaceInsideBrackets: { enabled: false }
|
||||
Rubocop/Style/BracesAroundHashParameters: { enabled: false}
|
||||
Rubocop/Style/EmptyLinesAroundAccessModifier: { enabled: false }
|
||||
Rubocop/Style/EmptyLinesAroundModuleBody: { enabled: false }
|
||||
Rubocop/Lint/FormatParameterMismatch: { enabled: false }
|
||||
Rubocop/Lint/UselessAccessModifier: { enabled: false }
|
||||
Rubocop/Lint/AssignmentInCondition: { enabled: false }
|
||||
Rubocop/Style/SpaceAroundOperators: { enabled: false }
|
||||
Rubocop/Style/AlignParameters: { enabled: false }
|
||||
Rubocop/Style/SignalException: { enabled: false }
|
||||
Rubocop/Style/Documentation: { enabled: false }
|
||||
Rubocop/Style/DoubleNegation: { enabled: false }
|
||||
Rubocop/Style/UnneededCapitalW: { enabled: false }
|
||||
Rubocop/Style/IfUnlessModifier: { enabled: false }
|
||||
Rubocop/Style/RescueModifier: { enabled: false }
|
||||
Rubocop/Style/RegexpLiteral: { enabled: false }
|
||||
Rubocop/Style/GuardClause: { enabled: false }
|
||||
Rubocop/Style/FileName: { enabled: false }
|
||||
fixme:
|
||||
enabled: false
|
||||
exclude_paths:
|
||||
- .rubocop.yml
|
||||
- .codeclimate.yml
|
||||
- .travis.yml
|
||||
- .gitignore
|
||||
- .rspec
|
||||
|
||||
- Gemfile.lock
|
||||
- CHANGELOG.md
|
||||
- readme.md
|
||||
- README.md
|
||||
- Readme.md
|
||||
- ReadMe.md
|
||||
- COPYING
|
||||
- LICENSE
|
||||
|
||||
- test/**/*
|
||||
- script/**/*
|
||||
- spec/**/*
|
||||
ratings:
|
||||
paths:
|
||||
- lib/**/*
|
|
@ -18,3 +18,4 @@ tmp/*
|
|||
.jekyll-metadata
|
||||
/vendor
|
||||
/test/source/file_name.txt
|
||||
.analysis
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
Style/IndentHash: { EnforcedStyle: align_braces }
|
||||
Style/StringLiteralsInInterpolation: { EnforcedStyle: double_quotes }
|
||||
Style/StringLiterals: { EnforcedStyle: none }
|
||||
Metrics/MethodLength: { Max: 24 }
|
||||
Metrics/ClassLength: { Max: 240 }
|
||||
Metrics/ModuleLength: { Max: 240 }
|
||||
Metrics/LineLength: { Max: 112 }
|
||||
|
||||
Style/HashSyntax:
|
||||
UseHashRocketsWithSymbolValues: false
|
||||
SupportedStyles: [ruby19 ruby19_no_mixed_keys, hash_rockets]
|
||||
EnforcedStyle: ruby19
|
||||
|
||||
Style/MultilineOperationIndentation:
|
||||
EnforcedStyle: indented
|
||||
SupportedStyles:
|
||||
- indented
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
PreferredDelimiters:
|
||||
'%q': '{}'
|
||||
'%Q': '{}'
|
||||
'%r': '!!'
|
||||
'%s': '()'
|
||||
'%w': '()'
|
||||
'%W': '()'
|
||||
'%x': '()'
|
37
Rakefile
37
Rakefile
|
@ -329,3 +329,40 @@ namespace :docs do
|
|||
sh "mv #{docs_name}-#{version}.gem pkg"
|
||||
end
|
||||
end
|
||||
|
||||
task :analysis do
|
||||
require "jekyll/utils/ansi"
|
||||
require "open3"
|
||||
|
||||
cmd = [
|
||||
"docker", "run", "--rm", "--env=CODE_PATH=#{Dir.pwd}", \
|
||||
"--volume='#{Dir.pwd}:/code'", "--volume=/var/run/docker.sock:/var/run/docker.sock", \
|
||||
"--volume=/tmp/cc:/tmp/cc", "-i", "codeclimate/codeclimate", "analyze"
|
||||
]
|
||||
|
||||
ansi = Jekyll::Utils::Ansi
|
||||
file = File.open(".analysis", "w+")
|
||||
Open3.popen3(cmd.shelljoin) do |_, out, err, _|
|
||||
while data = out.gets
|
||||
file.write data
|
||||
if data =~ /\A==/
|
||||
$stdout.print ansi.yellow(data)
|
||||
|
||||
elsif data !~ %r!\A[0-9\-]+!
|
||||
$stdout.puts data
|
||||
|
||||
else
|
||||
h, d = data.split(":", 2)
|
||||
$stdout.print ansi.cyan(h)
|
||||
$stdout.print ":", d
|
||||
end
|
||||
end
|
||||
|
||||
while data = err.gets
|
||||
file.write data
|
||||
$stderr.print ansi.red(data)
|
||||
end
|
||||
end
|
||||
|
||||
file.close
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module Jekyll
|
||||
module Utils extend self
|
||||
autoload :Platforms, 'jekyll/utils/platforms'
|
||||
autoload :Ansi, "jekyll/utils/ansi"
|
||||
|
||||
# Constants for use in #slugify
|
||||
SLUGIFY_MODES = %w{raw default pretty}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
# Frozen-string-literal: true
|
||||
# Copyright: 2015 Jekyll - MIT License
|
||||
# Encoding: utf-8
|
||||
|
||||
module Jekyll
|
||||
module Utils
|
||||
module Ansi
|
||||
extend self
|
||||
|
||||
ESCAPE = format("%c", 27)
|
||||
MATCH = /#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m/ix.freeze
|
||||
COLORS = {
|
||||
:red => 31,
|
||||
:green => 32,
|
||||
:black => 30,
|
||||
:magenta => 35,
|
||||
:yellow => 33,
|
||||
:white => 37,
|
||||
:blue => 34,
|
||||
:cyan => 36
|
||||
}
|
||||
|
||||
# Strip ANSI from the current string. It also strips cursor stuff,
|
||||
# well some of it, and it also strips some other stuff that a lot of
|
||||
# the other ANSI strippers don't.
|
||||
|
||||
def strip(str)
|
||||
str.gsub MATCH, ""
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
def has?(str)
|
||||
!!(str =~ MATCH)
|
||||
end
|
||||
|
||||
# Reset the color back to the default color so that you do not leak any
|
||||
# colors when you move onto the next line. This is probably normally
|
||||
# used as part of a wrapper so that we don't leak colors.
|
||||
|
||||
def reset(str = "")
|
||||
@ansi_reset ||= format("%c[0m", 27)
|
||||
"#{@ansi_reset}#{str}"
|
||||
end
|
||||
|
||||
# SEE: `self::COLORS` for a list of methods. They are mostly
|
||||
# standard base colors supported by pretty much any xterm-color, we do
|
||||
# not need more than the base colors so we do not include them.
|
||||
# Actually... if I'm honest we don't even need most of the
|
||||
# base colors.
|
||||
|
||||
COLORS.each do |color, num|
|
||||
define_method color do |str|
|
||||
"#{format("%c", 27)}[#{num}m#{str}#{reset}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
module Jekyll
|
||||
module Utils
|
||||
module Platforms extend self
|
||||
module Platforms
|
||||
extend self
|
||||
|
||||
# Provides jruby? and mri? which respectively detect these two types of
|
||||
# tested Engines we support, in the future we might probably support the
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
require "helper"
|
||||
|
||||
class TestAnsi < JekyllUnitTest
|
||||
context nil do
|
||||
setup do
|
||||
@subject = Jekyll::Utils::Ansi
|
||||
end
|
||||
|
||||
Jekyll::Utils::Ansi::COLORS.each do |color, val|
|
||||
should "respond_to? #{color}" do
|
||||
assert @subject.respond_to?(color)
|
||||
end
|
||||
end
|
||||
|
||||
should "be able to strip colors" do
|
||||
assert_equal @subject.strip(@subject.yellow(@subject.red("hello"))), "hello"
|
||||
end
|
||||
|
||||
should "be able to detect colors" do
|
||||
assert @subject.has?(@subject.yellow("hello"))
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue