codeclimate 0.9.7 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5ec325a3de6407e16d0ec265e3512751dc98d16
4
- data.tar.gz: 6902de17324c521e01d589e65fdedaf12b893808
3
+ metadata.gz: e7e316d10f1c30a533dd6bf12bec7489f950922a
4
+ data.tar.gz: 86754e8553d9286b76ade07489d0a3561e979d2f
5
5
  SHA512:
6
- metadata.gz: 40ad03e9e1d47bd3fc36d1e079d5d215493515518eb1f95a52869b514dc0bc6a1a668af0b84ee68359ebd351a7f0f711a5a339d7f90abcbf551ce8e0af573330
7
- data.tar.gz: 0fa3d26b50dbceeef4819d30db2d3cf0a9c6f5385cad4186d03c68b47b5ce3c6cbd103628043a04ab0f831a22a52cd9e011785e255bb66218f694669b161ec77
6
+ metadata.gz: e4a5711db9e980d5f061a40e207ae56d3882d1c540da778afc2cab5652e7fdd5c5ae217bae3f920e8f3095ee161976b0fd347598739e2db15babd899285ac5ad
7
+ data.tar.gz: 88b6924d353f1c61ac3dc59aae914ad809e1fdccb9683a01d8fa4f47dd6b35cf7a0e9b6cde45b9febb304e01a37619b9eb700fdc2029601d571b9c6726682f15
data/bin/prep-release CHANGED
@@ -14,6 +14,7 @@ fi
14
14
 
15
15
  version=$1
16
16
  old_version=$(< VERSION)
17
+ branch="release-$version"
17
18
 
18
19
  if ! bundle exec rake; then
19
20
  echo "test failure, not releasing" >&2
@@ -24,13 +25,13 @@ printf "RELEASE %s => %s\n" "$old_version" "$version"
24
25
  git checkout master
25
26
  git pull
26
27
 
27
- git checkout -b "release-$version"
28
+ git checkout -b $branch
28
29
 
29
30
  printf "%s\n" "$version" > VERSION
30
31
  bundle
31
32
  git add VERSION Gemfile.lock
32
33
  git commit -m "Release v$version"
33
- git push
34
+ git push origin $branch
34
35
 
35
36
  if command -v gh > /dev/null 2>&1; then
36
37
  gh pull-request -m "Release v$version"
data/config/engines.yml CHANGED
@@ -25,6 +25,12 @@ duplication:
25
25
  community: false
26
26
  enable_regexps:
27
27
  default_ratings_paths:
28
+ default_config:
29
+ languages:
30
+ - ruby
31
+ - javascript
32
+ - python
33
+ - php
28
34
  gofmt:
29
35
  image: codeclimate/codeclimate-gofmt
30
36
  description: gofmt
@@ -134,7 +140,8 @@ fixme:
134
140
  description: Find FIXME, TODO, HACK, etc. comments
135
141
  community: false
136
142
  enable_regexps:
137
- default_ratings_paths:
143
+ - .+
144
+ default_ratings_paths: []
138
145
  foodcritic:
139
146
  image: codeclimate/codeclimate-foodcritic
140
147
  description: Lint tool for Chef cookbooks
@@ -5,7 +5,7 @@ module CC
5
5
  # TODO: replace each use of this with CC::Yaml and remove it
6
6
  class Config
7
7
  def initialize(config_body)
8
- @config = YAML.safe_load(config_body) || {"engines"=> {} }
8
+ @config = YAML.safe_load(config_body) || { "engines" => {} }
9
9
  @config["engines"] ||= {}
10
10
 
11
11
  expand_shorthand
@@ -35,7 +35,10 @@ module CC
35
35
  if engine_present?(engine_name)
36
36
  @config["engines"][engine_name]["enabled"] = true
37
37
  else
38
- @config["engines"][engine_name] = { "enabled" => true }
38
+ @config["engines"][engine_name] = {
39
+ "enabled" => true,
40
+ "config" => default_config(engine_name),
41
+ }
39
42
  end
40
43
  end
41
44
 
@@ -59,7 +62,7 @@ module CC
59
62
  @config.to_yaml
60
63
  end
61
64
 
62
- private
65
+ private
63
66
 
64
67
  def expand_shorthand
65
68
  @config["engines"].each do |name, engine_config|
@@ -68,6 +71,16 @@ module CC
68
71
  end
69
72
  end
70
73
  end
74
+
75
+ def default_config(engine_name)
76
+ if (engine_config = engine_registry[engine_name])
77
+ engine_config["default_config"]
78
+ end
79
+ end
80
+
81
+ def engine_registry
82
+ @engine_registry ||= CC::Analyzer::EngineRegistry.new
83
+ end
71
84
  end
72
85
  end
73
86
  end
@@ -28,7 +28,7 @@ module CC
28
28
  @listener = listener
29
29
  @timeout = timeout
30
30
  @output_delimeter = "\n"
31
- @on_output = ->(*) { }
31
+ @on_output = ->(*) {}
32
32
  @timed_out = false
33
33
  @stderr_io = StringIO.new
34
34
  end
@@ -68,7 +68,7 @@ module CC
68
68
 
69
69
  def stop
70
70
  # Prevents the processing of more output after first error
71
- @on_output = ->(*) { }
71
+ @on_output = ->(*) {}
72
72
 
73
73
  reap_running_container
74
74
  end
@@ -82,7 +82,7 @@ module CC
82
82
  "--name", @name,
83
83
  options,
84
84
  @image,
85
- @command,
85
+ @command
86
86
  ].flatten.compact
87
87
  end
88
88
 
@@ -53,7 +53,7 @@ module CC
53
53
  "--net", "none",
54
54
  "--volume", "#{@code_path}:/code:ro",
55
55
  "--volume", "#{config_file}:/config.json:ro",
56
- "--user", "9000:9000",
56
+ "--user", "9000:9000"
57
57
  ]
58
58
  end
59
59
 
@@ -36,4 +36,3 @@ module CC
36
36
  end
37
37
  end
38
38
  end
39
-
@@ -28,7 +28,7 @@ module CC
28
28
  def engine_config(raw_engine_config)
29
29
  config = raw_engine_config.merge(
30
30
  exclude_paths: exclude_paths,
31
- include_paths: include_paths
31
+ include_paths: include_paths,
32
32
  )
33
33
  # The yaml gem turns a config file string into a hash, but engines
34
34
  # expect the string. So we (for now) need to turn it into a string in
@@ -37,7 +37,7 @@ module CC
37
37
  config: @config,
38
38
  container_label: @container_label,
39
39
  source_dir: @source_dir,
40
- requested_paths: @requested_paths
40
+ requested_paths: @requested_paths,
41
41
  )
42
42
  end
43
43
 
@@ -1,7 +1,6 @@
1
1
  module CC
2
2
  module Analyzer
3
3
  class Filesystem
4
-
5
4
  def initialize(root)
6
5
  @root = root
7
6
  end
@@ -40,7 +39,7 @@ module CC
40
39
  def file_paths
41
40
  @file_paths ||= Dir.chdir(@root) do
42
41
  `find . -type f -print0`.strip.split("\0").map do |path|
43
- path.sub(/^\.\//, "")
42
+ path.sub(%r{^\.\/}, "")
44
43
  end
45
44
  end
46
45
  end
@@ -1,9 +1,9 @@
1
1
  module CC
2
2
  module Analyzer
3
3
  module Formatters
4
- autoload :Formatter, "cc/analyzer/formatters/formatter"
4
+ autoload :Formatter, "cc/analyzer/formatters/formatter"
5
5
  autoload :JSONFormatter, "cc/analyzer/formatters/json_formatter"
6
- autoload :PlainTextFormatter, "cc/analyzer/formatters/plain_text_formatter"
6
+ autoload :PlainTextFormatter, "cc/analyzer/formatters/plain_text_formatter"
7
7
  autoload :Spinner, "cc/analyzer/formatters/spinner"
8
8
 
9
9
  FORMATTERS = {
@@ -12,7 +12,7 @@ module CC
12
12
  }.freeze
13
13
 
14
14
  def self.resolve(name)
15
- FORMATTERS[name.to_sym] or raise InvalidFormatterError, "'#{name}' is not a valid formatter. Valid options are: #{FORMATTERS.keys.join(", ")}"
15
+ FORMATTERS[name.to_sym] or raise InvalidFormatterError, "'#{name}' is not a valid formatter. Valid options are: #{FORMATTERS.keys.join(', ')}"
16
16
  end
17
17
  end
18
18
  end
@@ -7,7 +7,7 @@ module CC
7
7
  @output = output
8
8
  end
9
9
 
10
- def write(data)
10
+ def write(_data)
11
11
  end
12
12
 
13
13
  def started
@@ -26,7 +26,7 @@ module CC
26
26
  def close
27
27
  end
28
28
 
29
- def failed(output)
29
+ def failed(_output)
30
30
  end
31
31
 
32
32
  InvalidFormatterError = Class.new(StandardError)
@@ -2,7 +2,6 @@ module CC
2
2
  module Analyzer
3
3
  module Formatters
4
4
  class JSONFormatter < Formatter
5
-
6
5
  def initialize(filesystem)
7
6
  @filesystem = filesystem
8
7
  @has_begun = false
@@ -6,7 +6,6 @@ module CC
6
6
  module Analyzer
7
7
  module Formatters
8
8
  class PlainTextFormatter < Formatter
9
-
10
9
  def started
11
10
  puts colorize("Starting analysis", :green)
12
11
  end
@@ -21,7 +20,7 @@ module CC
21
20
  when "warning"
22
21
  warnings << json
23
22
  else
24
- raise "Invalid type found: #{json["type"]}"
23
+ raise "Invalid type found: #{json['type']}"
25
24
  end
26
25
  end
27
26
 
@@ -29,24 +28,24 @@ module CC
29
28
  puts
30
29
 
31
30
  issues_by_path.each do |path, file_issues|
32
- puts colorize("== #{path} (#{pluralize(file_issues.size, "issue")}) ==", :yellow)
31
+ puts colorize("== #{path} (#{pluralize(file_issues.size, 'issue')}) ==", :yellow)
33
32
 
34
33
  IssueSorter.new(file_issues).by_location.each do |issue|
35
- if location = issue["location"]
34
+ if (location = issue["location"])
36
35
  source_buffer = @filesystem.source_buffer_for(location["path"])
37
36
  print(colorize(LocationDescription.new(source_buffer, location, ": "), :cyan))
38
37
  end
39
38
 
40
39
  print(issue["description"])
41
- print(colorize(" [#{issue["engine_name"]}]", "#333333"))
40
+ print(colorize(" [#{issue['engine_name']}]", "#333333"))
42
41
  puts
43
42
  end
44
43
  puts
45
44
  end
46
45
 
47
- print(colorize("Analysis complete! Found #{pluralize(issues.size, "issue")}", :green))
46
+ print(colorize("Analysis complete! Found #{pluralize(issues.size, 'issue')}", :green))
48
47
  if warnings.size > 0
49
- print(colorize(" and #{pluralize(warnings.size, "warning")}", :green))
48
+ print(colorize(" and #{pluralize(warnings.size, 'warning')}", :green))
50
49
  end
51
50
  puts(colorize(".", :green))
52
51
  end
@@ -93,7 +92,7 @@ module CC
93
92
  end
94
93
 
95
94
  def issues_by_path
96
- issues.group_by { |i| i['location']['path'] }.sort
95
+ issues.group_by { |i| i["location"]["path"] }.sort
97
96
  end
98
97
 
99
98
  def warnings
@@ -13,29 +13,28 @@ module CC
13
13
  def decompose_position(position)
14
14
  line_no, line_begin = line_for(position)
15
15
 
16
- [ 1 + line_no, position - line_begin ]
16
+ [1 + line_no, position - line_begin]
17
17
  end
18
18
 
19
19
  def line_count
20
20
  @source.lines.count
21
21
  end
22
22
 
23
- private
23
+ private
24
24
 
25
25
  def line_for(position)
26
- line_begins.bsearch do |line, line_begin|
26
+ line_begins.bsearch do |_, line_begin|
27
27
  line_begin <= position
28
28
  end
29
29
  end
30
30
 
31
31
  def line_begins
32
32
  unless @line_begins
33
- @line_begins, index = [ [ 0, 0 ] ], 1
33
+ @line_begins = [[0, 0]]
34
+ index = 1
34
35
 
35
36
  @source.each_char do |char|
36
- if char == "\n"
37
- @line_begins.unshift [ @line_begins.length, index ]
38
- end
37
+ @line_begins.unshift [@line_begins.length, index] if char == "\n"
39
38
 
40
39
  index += 1
41
40
  end
@@ -43,7 +42,6 @@ module CC
43
42
 
44
43
  @line_begins
45
44
  end
46
-
47
45
  end
48
46
  end
49
47
  end
@@ -15,7 +15,7 @@ module CC
15
15
  def run
16
16
  require_codeclimate_yml
17
17
 
18
- Dir.chdir(ENV['FILESYSTEM_DIR']) do
18
+ Dir.chdir(ENV["FILESYSTEM_DIR"]) do
19
19
  runner = EnginesRunner.new(registry, formatter, source_dir, config, path_options)
20
20
  runner.run
21
21
  end
@@ -32,13 +32,13 @@ module CC
32
32
  attr_reader :engine_options, :path_options
33
33
 
34
34
  def process_args
35
- while arg = @args.shift
35
+ while (arg = @args.shift)
36
36
  case arg
37
- when '-f'
37
+ when "-f"
38
38
  @formatter = Formatters.resolve(@args.shift).new(filesystem)
39
- when '-e', '--engine'
39
+ when "-e", "--engine"
40
40
  @engine_options << @args.shift
41
- when '--dev'
41
+ when "--dev"
42
42
  @dev_mode = true
43
43
  else
44
44
  @path_options << arg
@@ -86,7 +86,7 @@ module CC
86
86
  if config.engines.include?(engine)
87
87
  config.engines[engine].enabled = true
88
88
  else
89
- config.engines[engine] = CC::Yaml::Nodes::Engine.new(config.engines).with_value({ "enabled" => true })
89
+ config.engines[engine] = CC::Yaml::Nodes::Engine.new(config.engines).with_value("enabled" => true)
90
90
  end
91
91
  end
92
92
  end
@@ -17,7 +17,7 @@ module CC
17
17
  end
18
18
 
19
19
  def self.command_name
20
- name[/[^:]*$/].split(/(?=[A-Z])/).map(&:downcase).join('-')
20
+ name[/[^:]*$/].split(/(?=[A-Z])/).map(&:downcase).join("-")
21
21
  end
22
22
 
23
23
  def execute
@@ -38,7 +38,7 @@ module CC
38
38
  end
39
39
 
40
40
  def require_codeclimate_yml
41
- if !filesystem.exist?(CODECLIMATE_YAML)
41
+ unless filesystem.exist?(CODECLIMATE_YAML)
42
42
  fatal("No '.codeclimate.yml' file found. Run 'codeclimate init' to generate a config file.")
43
43
  end
44
44
  end
@@ -54,7 +54,7 @@ module CC
54
54
  end
55
55
 
56
56
  def filesystem
57
- @filesystem ||= CC::Analyzer::Filesystem.new(ENV['FILESYSTEM_DIR'])
57
+ @filesystem ||= CC::Analyzer::Filesystem.new(ENV["FILESYSTEM_DIR"])
58
58
  end
59
59
 
60
60
  def terminal
data/lib/cc/cli/config.rb CHANGED
@@ -5,7 +5,7 @@ module CC
5
5
  def initialize
6
6
  @config = {
7
7
  "engines" => {},
8
- "ratings" => { "paths" => [] }
8
+ "ratings" => { "paths" => [] },
9
9
  }
10
10
  end
11
11
 
@@ -33,7 +33,7 @@ module CC
33
33
  end
34
34
 
35
35
  def pull_engine_image(engine_image)
36
- if !system("docker pull #{engine_image}")
36
+ unless system("docker pull #{engine_image}")
37
37
  raise ImagePullFailure, "unable to pull image #{engine_image}"
38
38
  end
39
39
  end
@@ -5,7 +5,7 @@ module CC
5
5
  def run
6
6
  say "Available engines:"
7
7
  engine_registry_list.sort_by { |name, _| name }.each do |name, attributes|
8
- say "- #{name}: #{attributes["description"]}"
8
+ say "- #{name}: #{attributes['description']}"
9
9
  end
10
10
  end
11
11
  end
data/lib/cc/cli/help.rb CHANGED
@@ -24,12 +24,12 @@ module CC
24
24
  "help",
25
25
  "init",
26
26
  "validate-config",
27
- "version"
27
+ "version",
28
28
  ].freeze
29
29
  end
30
30
 
31
31
  def underline(string)
32
- return Rainbow.new.wrap(string).underline
32
+ Rainbow.new.wrap(string).underline
33
33
  end
34
34
  end
35
35
  end
data/lib/cc/cli/init.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'cc/cli/config'
2
- require 'cc/cli/config_generator'
3
- require 'cc/cli/upgrade_config_generator'
1
+ require "cc/cli/config"
2
+ require "cc/cli/config_generator"
3
+ require "cc/cli/upgrade_config_generator"
4
4
 
5
5
  module CC
6
6
  module CLI
@@ -54,7 +54,7 @@ module CC
54
54
  Dir.glob("#{engine_directory}/*", File::FNM_DOTMATCH)
55
55
  end
56
56
 
57
- all_paths.reject { |path| ['.', '..'].include?(File.basename(path)) }
57
+ all_paths.reject { |path| [".", ".."].include?(File.basename(path)) }
58
58
  end
59
59
 
60
60
  def engines_enabled?
data/lib/cc/cli/runner.rb CHANGED
@@ -5,7 +5,6 @@ require "safe_yaml"
5
5
  module CC
6
6
  module CLI
7
7
  class Runner
8
-
9
8
  def self.run(argv)
10
9
  new(argv).run
11
10
  rescue => ex
@@ -44,8 +43,8 @@ module CC
44
43
 
45
44
  def command_name
46
45
  case command
47
- when nil, '-h', '-?', '--help' then 'Help'
48
- when '-v', '--version' then 'Version'
46
+ when nil, "-h", "-?", "--help" then "Help"
47
+ when "-v", "--version" then "Version"
49
48
  else command.sub(":", "::").underscore.camelize
50
49
  end
51
50
  end
@@ -57,7 +56,6 @@ module CC
57
56
  def command
58
57
  @args.first
59
58
  end
60
-
61
59
  end
62
60
  end
63
61
  end
@@ -6,6 +6,7 @@ module CC
6
6
  end
7
7
 
8
8
  private
9
+
9
10
  def version
10
11
  path = File.expand_path("../../../../VERSION", __FILE__)
11
12
  @version ||= File.read(path)
@@ -1,4 +1,4 @@
1
- require 'fileutils'
1
+ require "fileutils"
2
2
 
3
3
  module FileUtils
4
4
  def self.readable_by_all?(path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code Climate
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-27 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport