codeclimate-services 1.6.1 → 1.7.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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -0
  3. data/.rubocop.yml +1 -0
  4. data/Gemfile +1 -2
  5. data/Rakefile +4 -7
  6. data/base_rubocop.yml +152 -0
  7. data/bin/bundler +5 -5
  8. data/bin/coderay +5 -5
  9. data/bin/nokogiri +5 -5
  10. data/bin/pry +5 -5
  11. data/bin/rake +5 -5
  12. data/codeclimate-services.gemspec +15 -15
  13. data/config/load.rb +2 -2
  14. data/lib/cc/formatters/linked_formatter.rb +2 -2
  15. data/lib/cc/formatters/snapshot_formatter.rb +10 -10
  16. data/lib/cc/formatters/ticket_formatter.rb +0 -2
  17. data/lib/cc/helpers/quality_helper.rb +2 -2
  18. data/lib/cc/helpers/vulnerability_helper.rb +0 -2
  19. data/lib/cc/presenters/pull_requests_presenter.rb +1 -5
  20. data/lib/cc/pull_requests.rb +7 -3
  21. data/lib/cc/service.rb +9 -10
  22. data/lib/cc/service/formatter.rb +3 -3
  23. data/lib/cc/service/helper.rb +2 -3
  24. data/lib/cc/service/http.rb +9 -9
  25. data/lib/cc/service/invocation.rb +6 -6
  26. data/lib/cc/service/invocation/with_error_handling.rb +9 -8
  27. data/lib/cc/service/invocation/with_metrics.rb +4 -4
  28. data/lib/cc/service/invocation/with_return_values.rb +0 -1
  29. data/lib/cc/service/response_check.rb +4 -5
  30. data/lib/cc/services.rb +2 -2
  31. data/lib/cc/services/asana.rb +8 -9
  32. data/lib/cc/services/campfire.rb +2 -3
  33. data/lib/cc/services/flowdock.rb +5 -5
  34. data/lib/cc/services/github_issues.rb +6 -7
  35. data/lib/cc/services/github_pull_requests.rb +42 -5
  36. data/lib/cc/services/gitlab_merge_requests.rb +6 -2
  37. data/lib/cc/services/hipchat.rb +3 -4
  38. data/lib/cc/services/jira.rb +8 -9
  39. data/lib/cc/services/lighthouse.rb +4 -5
  40. data/lib/cc/services/pivotal_tracker.rb +6 -7
  41. data/lib/cc/services/slack.rb +8 -8
  42. data/lib/cc/services/stash_pull_requests.rb +2 -2
  43. data/lib/cc/services/version.rb +1 -1
  44. data/pull_request_test.rb +11 -10
  45. data/service_test.rb +5 -5
  46. data/spec/axiom/types/password_spec.rb +14 -0
  47. data/spec/cc/formatters/snapshot_formatter_spec.rb +44 -0
  48. data/spec/cc/presenters/pull_requests_presenter_spec.rb +45 -0
  49. data/{test/asana_test.rb → spec/cc/service/asana_spec.rb} +27 -29
  50. data/{test/campfire_test.rb → spec/cc/service/campfire_spec.rb} +40 -44
  51. data/{test/flowdock_test.rb → spec/cc/service/flowdock_spec.rb} +46 -48
  52. data/{test/github_issues_test.rb → spec/cc/service/github_issues_spec.rb} +33 -35
  53. data/spec/cc/service/github_pull_requests_spec.rb +223 -0
  54. data/{test/gitlab_merge_requests_test.rb → spec/cc/service/gitlab_merge_requests_spec.rb} +30 -35
  55. data/{test/hipchat_test.rb → spec/cc/service/hipchat_spec.rb} +38 -40
  56. data/spec/cc/service/invocation/error_handling_spec.rb +49 -0
  57. data/spec/cc/service/invocation/return_values_spec.rb +19 -0
  58. data/spec/cc/service/invocation/with_metrics_spec.rb +18 -0
  59. data/{test/invocation_test.rb → spec/cc/service/invocation_spec.rb} +31 -34
  60. data/{test/jira_test.rb → spec/cc/service/jira_spec.rb} +25 -27
  61. data/{test/lighthouse_test.rb → spec/cc/service/lighthouse_spec.rb} +23 -26
  62. data/spec/cc/service/pivotal_tracker_spec.rb +70 -0
  63. data/{test/slack_test.rb → spec/cc/service/slack_spec.rb} +66 -77
  64. data/spec/cc/service/stash_pull_requests_spec.rb +132 -0
  65. data/spec/cc/service_spec.rb +78 -0
  66. data/{test → spec}/fixtures.rb +3 -4
  67. data/spec/spec_helper.rb +37 -0
  68. data/{test → spec}/support/fake_logger.rb +0 -0
  69. data/spec/support/service_context.rb +42 -0
  70. metadata +57 -52
  71. data/test/axiom/types/password_test.rb +0 -22
  72. data/test/formatters/snapshot_formatter_test.rb +0 -47
  73. data/test/github_pull_requests_test.rb +0 -217
  74. data/test/helper.rb +0 -58
  75. data/test/invocation_error_handling_test.rb +0 -51
  76. data/test/invocation_return_values_test.rb +0 -21
  77. data/test/pivotal_tracker_test.rb +0 -73
  78. data/test/presenters/pull_requests_presenter_test.rb +0 -70
  79. data/test/service_test.rb +0 -84
  80. data/test/stash_pull_requests_test.rb +0 -146
  81. data/test/with_metrics_test.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5743e344af855362cf8d9de84add9de905ddef4
4
- data.tar.gz: 30a6496f74f2ab59c32bacf37435ebf2a85c5649
3
+ metadata.gz: 08767ab67555c51f2f492eea001853158febb41b
4
+ data.tar.gz: f097a06a711a69a01014dc8775bc99f2176bd028
5
5
  SHA512:
6
- metadata.gz: 8fceef45fc66347e24f12790454d427be003e8fbdc3dec77849d8c3b0692323b1e56439bcd6baf9fce75859e6a8971607edaba0f9281ff860777c5e6f631d13a
7
- data.tar.gz: 404ea8ec662df618b3a8e7e0077dbeb79cbdde38f4899c7c07edc8b921c6d1223537da59c023666d038cbf7a5467453820f2be788e54b87faf5904a157de0da3
6
+ metadata.gz: a668a902b808e680c2a0a350506313dcd87b12cbce904d634197c5a109be59a6f6009801dafd841d7df3d69fe7aa6bd2dd7a00c75d8cb067bdebf77c332340a6
7
+ data.tar.gz: fe1911f20809ac655ec9b94d8cb35394173a9592bd865d683c4c39ffa63aef3c9aa2867d7e8480bdf99299e00e168d204cb418e4bf1e95f064142f7257bffd9e
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: base_rubocop.yml
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in codeclimate-services.gemspec
4
4
  gemspec
5
5
 
6
6
  gem "pry"
7
- gem "codeclimate-test-reporter"
data/Rakefile CHANGED
@@ -1,11 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
- require 'rake/testtask'
2
+ require "rspec/core/rake_task"
3
3
 
4
- Rake::TestTask.new do |t|
5
- t.libs.push "lib"
6
- t.libs.push "test"
7
- t.test_files = FileList['test/**/*_test.rb']
8
- t.verbose = true
4
+ RSpec::Core::RakeTask.new(:spec) do |task|
5
+ task.ruby_opts = "-W"
9
6
  end
10
7
 
11
- task :default => :test
8
+ task default: :spec
data/base_rubocop.yml ADDED
@@ -0,0 +1,152 @@
1
+ ################################################################################
2
+ # Metrics
3
+ ################################################################################
4
+
5
+ Metrics/LineLength:
6
+ Enabled: false
7
+
8
+ Metrics/AbcSize:
9
+ Enabled: false
10
+
11
+ ################################################################################
12
+ # Style
13
+ ################################################################################
14
+
15
+ # Executables are conventionally named bin/foo-bar
16
+ Style/FileName:
17
+ Exclude:
18
+ - bin/**/*
19
+
20
+ # We don't (currently) document our code
21
+ Style/Documentation:
22
+ Enabled: false
23
+
24
+ # Always use double-quotes to keep things simple
25
+ Style/StringLiterals:
26
+ EnforcedStyle: double_quotes
27
+
28
+ Style/StringLiteralsInInterpolation:
29
+ EnforcedStyle: double_quotes
30
+
31
+ # Use a trailing comma to keep diffs clean when elements are inserted or removed
32
+ Style/TrailingCommaInArguments:
33
+ EnforcedStyleForMultiline: comma
34
+
35
+ Style/TrailingCommaInLiteral:
36
+ EnforcedStyleForMultiline: comma
37
+
38
+ # We avoid GuardClause because it can result in "suprise return"
39
+ Style/GuardClause:
40
+ Enabled: false
41
+
42
+ # We avoid IfUnlessModifier because it can result in "suprise if"
43
+ Style/IfUnlessModifier:
44
+ Enabled: false
45
+
46
+ # We don't care about the fail/raise distinction
47
+ Style/SignalException:
48
+ EnforcedStyle: only_raise
49
+
50
+ Style/DotPosition:
51
+ EnforcedStyle: trailing
52
+
53
+ # Common globals we allow
54
+ Style/GlobalVars:
55
+ AllowedVariables:
56
+ - "$statsd"
57
+ - "$mongo"
58
+ - "$rollout"
59
+
60
+ # Using english names requires loading an extra module, which is annoying, so
61
+ # we prefer the perl names for consistency.
62
+ Style/SpecialGlobalVars:
63
+ EnforcedStyle: use_perl_names
64
+
65
+ # We have common cases where has_ and have_ make sense
66
+ Style/PredicateName:
67
+ Enabled: true
68
+ NamePrefixBlacklist:
69
+ - is_
70
+
71
+ # We use %w[ ], not %w( ) because the former looks like an array
72
+ Style/PercentLiteralDelimiters:
73
+ PreferredDelimiters:
74
+ "%i": "[]"
75
+ "%I": "[]"
76
+ "%w": "[]"
77
+ "%W": "[]"
78
+
79
+ # Allow "trivial" accessors when defined as a predicate? method
80
+ Style/TrivialAccessors:
81
+ AllowPredicates: true
82
+
83
+ Style/Next:
84
+ Enabled: false
85
+
86
+ # We think it's OK to use the "extend self" module pattern
87
+ Style/ModuleFunction:
88
+ Enabled: false
89
+
90
+ # Disallow extra spacing for token alignment
91
+ Style/ExtraSpacing:
92
+ AllowForAlignment: false
93
+
94
+ # and/or in conditionals has no meaningful difference (only gotchas), so we
95
+ # disallow them there. When used for control flow, the difference in precedence
96
+ # can make for a less noisy expression, as in:
97
+ #
98
+ # x = find_x or raise XNotFound
99
+ #
100
+ Style/AndOr:
101
+ EnforcedStyle: conditionals
102
+
103
+ Style/AlignParameters:
104
+ EnforcedStyle: with_fixed_indentation
105
+
106
+ Style/MultilineOperationIndentation:
107
+ EnforcedStyle: indented
108
+
109
+ Style/AlignHash:
110
+ EnforcedLastArgumentHashStyle: ignore_implicit
111
+
112
+ # This has the behavior we want, but it has a bug in it which produces a lot of false positives
113
+ # https://github.com/bbatsov/rubocop/issues/3462
114
+ # MultilineMethodCallBraceLayout:
115
+ # EnforcedStyle: new_line
116
+
117
+ ################################################################################
118
+ # Performance
119
+ ################################################################################
120
+
121
+ Performance/RedundantMerge:
122
+ Enabled: false
123
+
124
+ ################################################################################
125
+ # Rails - disable things because we're primarily non-rails
126
+ ################################################################################
127
+
128
+ Rails/Delegate:
129
+ Enabled: false
130
+
131
+ Rails/TimeZone:
132
+ Enabled: false
133
+
134
+ ################################################################################
135
+ # Specs - be more lenient on length checks and block styles
136
+ ################################################################################
137
+
138
+ Metrics/ModuleLength:
139
+ Exclude:
140
+ - spec/**/*
141
+
142
+ Metrics/MethodLength:
143
+ Exclude:
144
+ - spec/**/*
145
+
146
+ Style/ClassAndModuleChildren:
147
+ Exclude:
148
+ - spec/**/*
149
+
150
+ Style/BlockDelimiters:
151
+ Exclude:
152
+ - spec/**/*
data/bin/bundler CHANGED
@@ -6,11 +6,11 @@
6
6
  # this file is here to facilitate running it.
7
7
  #
8
8
 
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
11
  Pathname.new(__FILE__).realpath)
12
12
 
13
- require 'rubygems'
14
- require 'bundler/setup'
13
+ require "rubygems"
14
+ require "bundler/setup"
15
15
 
16
- load Gem.bin_path('codeclimate-services', 'bundler')
16
+ load Gem.bin_path("codeclimate-services", "bundler")
data/bin/coderay CHANGED
@@ -6,11 +6,11 @@
6
6
  # this file is here to facilitate running it.
7
7
  #
8
8
 
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
11
  Pathname.new(__FILE__).realpath)
12
12
 
13
- require 'rubygems'
14
- require 'bundler/setup'
13
+ require "rubygems"
14
+ require "bundler/setup"
15
15
 
16
- load Gem.bin_path('coderay', 'coderay')
16
+ load Gem.bin_path("coderay", "coderay")
data/bin/nokogiri CHANGED
@@ -6,11 +6,11 @@
6
6
  # this file is here to facilitate running it.
7
7
  #
8
8
 
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
11
  Pathname.new(__FILE__).realpath)
12
12
 
13
- require 'rubygems'
14
- require 'bundler/setup'
13
+ require "rubygems"
14
+ require "bundler/setup"
15
15
 
16
- load Gem.bin_path('nokogiri', 'nokogiri')
16
+ load Gem.bin_path("nokogiri", "nokogiri")
data/bin/pry CHANGED
@@ -6,11 +6,11 @@
6
6
  # this file is here to facilitate running it.
7
7
  #
8
8
 
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
11
  Pathname.new(__FILE__).realpath)
12
12
 
13
- require 'rubygems'
14
- require 'bundler/setup'
13
+ require "rubygems"
14
+ require "bundler/setup"
15
15
 
16
- load Gem.bin_path('pry', 'pry')
16
+ load Gem.bin_path("pry", "pry")
data/bin/rake CHANGED
@@ -6,11 +6,11 @@
6
6
  # this file is here to facilitate running it.
7
7
  #
8
8
 
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
11
  Pathname.new(__FILE__).realpath)
12
12
 
13
- require 'rubygems'
14
- require 'bundler/setup'
13
+ require "rubygems"
14
+ require "bundler/setup"
15
15
 
16
- load Gem.bin_path('codeclimate-services', 'rake')
16
+ load Gem.bin_path("codeclimate-services", "rake")
@@ -1,20 +1,20 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cc/services/version'
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $:.unshift(lib) unless $:.include?(lib)
4
+ require "cc/services/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "codeclimate-services"
8
- spec.version = CC::Services::VERSION
9
- spec.authors = ["Bryan Helmkamp"]
10
- spec.email = ["bryan@brynary.com"]
11
- spec.summary = %q{Service classes for Code Climate}
12
- spec.description = %q{Service classes for Code Climate}
13
- spec.homepage = ""
14
- spec.license = "MIT"
7
+ spec.name = "codeclimate-services"
8
+ spec.version = CC::Services::VERSION
9
+ spec.authors = ["Bryan Helmkamp"]
10
+ spec.email = ["bryan@brynary.com"]
11
+ spec.summary = "Service classes for Code Climate"
12
+ spec.description = "Service classes for Code Climate"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "faraday", "0.8.8"
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "activemodel", ">= 3.0"
24
24
  spec.add_dependency "activesupport", ">= 3.0"
25
25
  spec.add_development_dependency "bundler", ">= 1.6.2"
26
+ spec.add_development_dependency "codeclimate-test-reporter"
26
27
  spec.add_development_dependency "rake"
27
- spec.add_development_dependency "test-unit"
28
- spec.add_development_dependency "mocha"
28
+ spec.add_development_dependency "rspec"
29
29
  end
data/config/load.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
1
+ require "rubygems"
2
+ require "bundler/setup"
3
3
 
4
4
  require File.expand_path("../../lib/cc/services", __FILE__)
@@ -8,7 +8,7 @@ module CC
8
8
 
9
9
  def format_coverage
10
10
  message = message_prefix
11
- message << "#{format_link(details_url, "Test coverage")}"
11
+ message << format_link(details_url, "Test coverage").to_s
12
12
  message << " has #{changed} to #{covered_percent}% (#{delta})"
13
13
 
14
14
  if compare_url
@@ -20,7 +20,7 @@ module CC
20
20
 
21
21
  def format_quality
22
22
  message = message_prefix
23
- message << "#{format_link(details_url, constant_name)}"
23
+ message << format_link(details_url, constant_name).to_s
24
24
  message << " has #{changed} from #{previous_rating} to #{rating}"
25
25
 
26
26
  if compare_url
@@ -21,7 +21,7 @@ module CC::Formatters
21
21
  end
22
22
 
23
23
  def inspect
24
- "<Rating:#{to_s}>"
24
+ "<Rating:#{self}>"
25
25
  end
26
26
 
27
27
  def to_s
@@ -52,25 +52,25 @@ module CC::Formatters
52
52
 
53
53
  data = {
54
54
  "from" => { "commit_sha" => payload["previous_commit_sha"] },
55
- "to" => { "commit_sha" => payload["commit_sha"] }
55
+ "to" => { "commit_sha" => payload["commit_sha"] },
56
56
  }
57
57
 
58
- @alert_constants_payload = data.merge("constants" => alert_constants) if alert_constants.any?
58
+ @alert_constants_payload = data.merge("constants" => alert_constants) if alert_constants.any?
59
59
  @improved_constants_payload = data.merge("constants" => improved_constants) if improved_constants.any?
60
60
  end
61
61
 
62
- private
62
+ private
63
63
 
64
64
  def new_constants_selector
65
- Proc.new { |constant| to_rating(constant) < C }
65
+ proc { |constant| to_rating(constant) < C }
66
66
  end
67
67
 
68
68
  def decreased_constants_selector
69
- Proc.new { |constant| from_rating(constant) > D && to_rating(constant) < C }
69
+ proc { |constant| from_rating(constant) > D && to_rating(constant) < C }
70
70
  end
71
71
 
72
72
  def improved_constants_selector
73
- Proc.new { |constant| from_rating(constant) < C && to_rating(constant) > from_rating(constant) }
73
+ proc { |constant| from_rating(constant) < C && to_rating(constant) > from_rating(constant) }
74
74
  end
75
75
 
76
76
  def to_rating(constant)
@@ -86,15 +86,15 @@ module CC::Formatters
86
86
  # This is useful to show more information for testing the service.
87
87
  class Sample < Base
88
88
  def new_constants_selector
89
- Proc.new { |_| true }
89
+ proc { |_| true }
90
90
  end
91
91
 
92
92
  def decreased_constants_selector
93
- Proc.new { |constant| to_rating(constant) < from_rating(constant) }
93
+ proc { |constant| to_rating(constant) < from_rating(constant) }
94
94
  end
95
95
 
96
96
  def improved_constants_selector
97
- Proc.new { |constant| to_rating(constant) > from_rating(constant) }
97
+ proc { |constant| to_rating(constant) > from_rating(constant) }
98
98
  end
99
99
  end
100
100
  end
@@ -1,7 +1,6 @@
1
1
  module CC
2
2
  module Formatters
3
3
  class TicketFormatter < CC::Service::Formatter
4
-
5
4
  def format_vulnerability_title
6
5
  if multiple?
7
6
  "#{vulnerabilities.size} new #{warning_type} issues found"
@@ -21,7 +20,6 @@ module CC
21
20
  message << ".\n\n"
22
21
  message << details_url
23
22
  end
24
-
25
23
  end
26
24
  end
27
25
  end
@@ -32,10 +32,10 @@ module CC::Service::QualityHelper
32
32
  end
33
33
 
34
34
  def with_article(letter, bold = false)
35
- letter ||= '?'
35
+ letter ||= "?"
36
36
 
37
37
  text = bold ? "*#{letter}*" : letter
38
- if %w( A F ).include?(letter.to_s)
38
+ if %w[A F].include?(letter.to_s)
39
39
  "an #{text}"
40
40
  else
41
41
  "a #{text}"