Commit 0149f83373d0b61386912d4a7ac55189e1c8d9c8
1 parent
6cd06830
Exists in
master
and in
1 other branch
Rubocop: fix non-standard constant names
Showing
13 changed files
with
38 additions
and
52 deletions
Show diff stats
.rubocop_todo.yml
| @@ -96,20 +96,6 @@ Style/ClassAndModuleChildren: | @@ -96,20 +96,6 @@ Style/ClassAndModuleChildren: | ||
| 96 | - 'app/models/notification_services/webhook_service.rb' | 96 | - 'app/models/notification_services/webhook_service.rb' |
| 97 | - 'config/initializers/overrides.rb' | 97 | - 'config/initializers/overrides.rb' |
| 98 | 98 | ||
| 99 | -# Offense count: 23 | ||
| 100 | -Style/ConstantName: | ||
| 101 | - Exclude: | ||
| 102 | - - 'app/models/notification_service.rb' | ||
| 103 | - - 'app/models/notification_services/campfire_service.rb' | ||
| 104 | - - 'app/models/notification_services/flowdock_service.rb' | ||
| 105 | - - 'app/models/notification_services/gtalk_service.rb' | ||
| 106 | - - 'app/models/notification_services/hipchat_service.rb' | ||
| 107 | - - 'app/models/notification_services/hoiio_service.rb' | ||
| 108 | - - 'app/models/notification_services/hubot_service.rb' | ||
| 109 | - - 'app/models/notification_services/pushover_service.rb' | ||
| 110 | - - 'app/models/notification_services/slack_service.rb' | ||
| 111 | - - 'app/models/notification_services/webhook_service.rb' | ||
| 112 | - | ||
| 113 | # Offense count: 70 | 99 | # Offense count: 70 |
| 114 | # Configuration parameters: Exclude. | 100 | # Configuration parameters: Exclude. |
| 115 | Style/Documentation: | 101 | Style/Documentation: |
app/models/notification_service.rb
| @@ -18,13 +18,13 @@ class NotificationService | @@ -18,13 +18,13 @@ class NotificationService | ||
| 18 | validate :check_params | 18 | validate :check_params |
| 19 | 19 | ||
| 20 | if Errbit::Config.per_app_notify_at_notices | 20 | if Errbit::Config.per_app_notify_at_notices |
| 21 | - Fields = [[:notify_at_notices, | 21 | + FIELDS = [[:notify_at_notices, |
| 22 | { :placeholder => 'comma separated numbers or simply 0 for every notice', | 22 | { :placeholder => 'comma separated numbers or simply 0 for every notice', |
| 23 | :label => 'notify on errors (0 for all errors)' | 23 | :label => 'notify on errors (0 for all errors)' |
| 24 | } | 24 | } |
| 25 | ]] | 25 | ]] |
| 26 | else | 26 | else |
| 27 | - Fields = [] | 27 | + FIELDS = [] |
| 28 | end | 28 | end |
| 29 | 29 | ||
| 30 | def notify_at_notices | 30 | def notify_at_notices |
| @@ -54,9 +54,9 @@ class NotificationService | @@ -54,9 +54,9 @@ class NotificationService | ||
| 54 | end | 54 | end |
| 55 | 55 | ||
| 56 | # Retrieve tracker label from either class or instance. | 56 | # Retrieve tracker label from either class or instance. |
| 57 | - Label = '' | 57 | + LABEL = '' |
| 58 | def self.label | 58 | def self.label |
| 59 | - self::Label | 59 | + self::LABEL |
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | def label | 62 | def label |
app/models/notification_services/campfire_service.rb
| 1 | if defined? Campy | 1 | if defined? Campy |
| 2 | class NotificationServices::CampfireService < NotificationService | 2 | class NotificationServices::CampfireService < NotificationService |
| 3 | - Label = "campfire" | ||
| 4 | - Fields += [ | 3 | + LABEL = "campfire" |
| 4 | + FIELDS += [ | ||
| 5 | [:subdomain, { | 5 | [:subdomain, { |
| 6 | :label => "Subdomain", | 6 | :label => "Subdomain", |
| 7 | :placeholder => "subdomain from http://{{subdomain}}.campfirenow.com" | 7 | :placeholder => "subdomain from http://{{subdomain}}.campfirenow.com" |
| @@ -17,7 +17,7 @@ if defined? Campy | @@ -17,7 +17,7 @@ if defined? Campy | ||
| 17 | ] | 17 | ] |
| 18 | 18 | ||
| 19 | def check_params | 19 | def check_params |
| 20 | - if Fields.detect {|f| self[f[0]].blank? } | 20 | + if FIELDS.detect {|f| self[f[0]].blank? } |
| 21 | errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID' | 21 | errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID' |
| 22 | end | 22 | end |
| 23 | end | 23 | end |
app/models/notification_services/flowdock_service.rb
| 1 | if defined? Flowdock | 1 | if defined? Flowdock |
| 2 | class NotificationServices::FlowdockService < NotificationService | 2 | class NotificationServices::FlowdockService < NotificationService |
| 3 | - Label = 'flowdock' | ||
| 4 | - Fields += [ | 3 | + LABEL = 'flowdock' |
| 4 | + FIELDS += [ | ||
| 5 | [ | 5 | [ |
| 6 | :api_token, { | 6 | :api_token, { |
| 7 | :label => 'Flow API Token', | 7 | :label => 'Flow API Token', |
| @@ -11,7 +11,7 @@ if defined? Flowdock | @@ -11,7 +11,7 @@ if defined? Flowdock | ||
| 11 | ] | 11 | ] |
| 12 | 12 | ||
| 13 | def check_params | 13 | def check_params |
| 14 | - if Fields.any? { |f, _| self[f].blank? } | 14 | + if FIELDS.any? { |f, _| self[f].blank? } |
| 15 | errors.add :base, 'You must specify your Flowdock(Flow) API token' | 15 | errors.add :base, 'You must specify your Flowdock(Flow) API token' |
| 16 | end | 16 | end |
| 17 | end | 17 | end |
app/models/notification_services/gtalk_service.rb
| 1 | class NotificationServices::GtalkService < NotificationService | 1 | class NotificationServices::GtalkService < NotificationService |
| 2 | - Label = "gtalk" | ||
| 3 | - Fields += [ | 2 | + LABEL = "gtalk" |
| 3 | + FIELDS += [ | ||
| 4 | [:subdomain, { | 4 | [:subdomain, { |
| 5 | :placeholder => "username@example.com", | 5 | :placeholder => "username@example.com", |
| 6 | :label => "Username" | 6 | :label => "Username" |
| @@ -28,7 +28,7 @@ class NotificationServices::GtalkService < NotificationService | @@ -28,7 +28,7 @@ class NotificationServices::GtalkService < NotificationService | ||
| 28 | ] | 28 | ] |
| 29 | 29 | ||
| 30 | def check_params | 30 | def check_params |
| 31 | - if Fields.detect { |f| self[f[0]].blank? && self[f[2]].blank? } | 31 | + if FIELDS.detect { |f| self[f[0]].blank? && self[f[2]].blank? } |
| 32 | errors.add :base, | 32 | errors.add :base, |
| 33 | """You must specify your Username, Password, service, service_url | 33 | """You must specify your Username, Password, service, service_url |
| 34 | and either rooms or users to send to or both""" | 34 | and either rooms or users to send to or both""" |
app/models/notification_services/hipchat_service.rb
| 1 | if defined? HipChat | 1 | if defined? HipChat |
| 2 | class NotificationServices::HipchatService < NotificationService | 2 | class NotificationServices::HipchatService < NotificationService |
| 3 | - Label = 'hipchat' | ||
| 4 | - Fields += [ | 3 | + LABEL = 'hipchat' |
| 4 | + FIELDS += [ | ||
| 5 | [:service, { | 5 | [:service, { |
| 6 | :placeholder => "'v1' (admin API token) or 'v2' (account API token)", | 6 | :placeholder => "'v1' (admin API token) or 'v2' (account API token)", |
| 7 | :label => "HipChat API version" | 7 | :label => "HipChat API version" |
| @@ -19,17 +19,17 @@ if defined? HipChat | @@ -19,17 +19,17 @@ if defined? HipChat | ||
| 19 | :label => "Room name" | 19 | :label => "Room name" |
| 20 | }] | 20 | }] |
| 21 | ] | 21 | ] |
| 22 | - Mandatory_fields = [:service, :api_token, :room_id] | ||
| 23 | - API_versions = %w(v1 v2) | 22 | + MANDATORY_FIELDS = [:service, :api_token, :room_id] |
| 23 | + API_VERSIONS = %w(v1 v2) | ||
| 24 | 24 | ||
| 25 | def check_params | 25 | def check_params |
| 26 | - Fields.each do |field, hash| | ||
| 27 | - if Mandatory_fields.include?(field) && self[field].blank? | 26 | + FIELDS.each do |field, hash| |
| 27 | + if MANDATORY_FIELDS.include?(field) && self[field].blank? | ||
| 28 | errors.add field, "You must specify #{hash[:label]}" | 28 | errors.add field, "You must specify #{hash[:label]}" |
| 29 | end | 29 | end |
| 30 | end | 30 | end |
| 31 | - unless API_versions.include?(self[:service]) | ||
| 32 | - errors.add :service, "API version must be #{API_versions.join(' or ')}" | 31 | + unless API_VERSIONS.include?(self[:service]) |
| 32 | + errors.add :service, "API version must be #{API_VERSIONS.join(' or ')}" | ||
| 33 | end | 33 | end |
| 34 | end | 34 | end |
| 35 | 35 |
app/models/notification_services/hoiio_service.rb
| 1 | class NotificationServices::HoiioService < NotificationService | 1 | class NotificationServices::HoiioService < NotificationService |
| 2 | - Label = "hoiio" | ||
| 3 | - Fields += [ | 2 | + LABEL = "hoiio" |
| 3 | + FIELDS += [ | ||
| 4 | [:api_token, { | 4 | [:api_token, { |
| 5 | :placeholder => "App ID", | 5 | :placeholder => "App ID", |
| 6 | :label => "App ID" | 6 | :label => "App ID" |
| @@ -16,7 +16,7 @@ class NotificationServices::HoiioService < NotificationService | @@ -16,7 +16,7 @@ class NotificationServices::HoiioService < NotificationService | ||
| 16 | ] | 16 | ] |
| 17 | 17 | ||
| 18 | def check_params | 18 | def check_params |
| 19 | - if Fields.detect {|f| self[f[0]].blank? } | 19 | + if FIELDS.detect {|f| self[f[0]].blank? } |
| 20 | errors.add :base, 'You must specify your App ID, Access Token and Recipient\'s phone numbers' | 20 | errors.add :base, 'You must specify your App ID, Access Token and Recipient\'s phone numbers' |
| 21 | end | 21 | end |
| 22 | end | 22 | end |
app/models/notification_services/hubot_service.rb
| 1 | class NotificationServices::HubotService < NotificationService | 1 | class NotificationServices::HubotService < NotificationService |
| 2 | - Label = "hubot" | ||
| 3 | - Fields += [ | 2 | + LABEL = "hubot" |
| 3 | + FIELDS += [ | ||
| 4 | [:api_token, { | 4 | [:api_token, { |
| 5 | :placeholder => 'http://hubot.example.org:8080/hubot/say', | 5 | :placeholder => 'http://hubot.example.org:8080/hubot/say', |
| 6 | :label => 'Hubot URL' | 6 | :label => 'Hubot URL' |
| @@ -12,7 +12,7 @@ class NotificationServices::HubotService < NotificationService | @@ -12,7 +12,7 @@ class NotificationServices::HubotService < NotificationService | ||
| 12 | ] | 12 | ] |
| 13 | 13 | ||
| 14 | def check_params | 14 | def check_params |
| 15 | - if Fields.detect {|f| self[f[0]].blank? } | 15 | + if FIELDS.detect {|f| self[f[0]].blank? } |
| 16 | errors.add :base, 'You must specify the URL of your hubot' | 16 | errors.add :base, 'You must specify the URL of your hubot' |
| 17 | end | 17 | end |
| 18 | end | 18 | end |
app/models/notification_services/pushover_service.rb
| 1 | class NotificationServices::PushoverService < NotificationService | 1 | class NotificationServices::PushoverService < NotificationService |
| 2 | - Label = "pushover" | ||
| 3 | - Fields += [ | 2 | + LABEL = "pushover" |
| 3 | + FIELDS += [ | ||
| 4 | [:api_token, { | 4 | [:api_token, { |
| 5 | :placeholder => "User Key", | 5 | :placeholder => "User Key", |
| 6 | :label => "User Key" | 6 | :label => "User Key" |
| @@ -12,7 +12,7 @@ class NotificationServices::PushoverService < NotificationService | @@ -12,7 +12,7 @@ class NotificationServices::PushoverService < NotificationService | ||
| 12 | ] | 12 | ] |
| 13 | 13 | ||
| 14 | def check_params | 14 | def check_params |
| 15 | - if Fields.detect {|f| self[f[0]].blank? } | 15 | + if FIELDS.detect {|f| self[f[0]].blank? } |
| 16 | errors.add :base, 'You must specify your User Key and Application API Token.' | 16 | errors.add :base, 'You must specify your User Key and Application API Token.' |
| 17 | end | 17 | end |
| 18 | end | 18 | end |
app/models/notification_services/slack_service.rb
| 1 | class NotificationServices::SlackService < NotificationService | 1 | class NotificationServices::SlackService < NotificationService |
| 2 | - Label = "slack" | ||
| 3 | - Fields += [ | 2 | + LABEL = "slack" |
| 3 | + FIELDS += [ | ||
| 4 | [:service_url, { | 4 | [:service_url, { |
| 5 | :placeholder => 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)', | 5 | :placeholder => 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)', |
| 6 | :label => 'Hook URL' | 6 | :label => 'Hook URL' |
| @@ -8,7 +8,7 @@ class NotificationServices::SlackService < NotificationService | @@ -8,7 +8,7 @@ class NotificationServices::SlackService < NotificationService | ||
| 8 | ] | 8 | ] |
| 9 | 9 | ||
| 10 | def check_params | 10 | def check_params |
| 11 | - if Fields.detect {|f| self[f[0]].blank? } | 11 | + if FIELDS.detect {|f| self[f[0]].blank? } |
| 12 | errors.add :base, "You must specify your Slack Hook url." | 12 | errors.add :base, "You must specify your Slack Hook url." |
| 13 | end | 13 | end |
| 14 | end | 14 | end |
app/models/notification_services/webhook_service.rb
| 1 | class NotificationServices::WebhookService < NotificationService | 1 | class NotificationServices::WebhookService < NotificationService |
| 2 | - Label = "webhook" | ||
| 3 | - Fields = [ | 2 | + LABEL = "webhook" |
| 3 | + FIELDS = [ | ||
| 4 | [:api_token, { | 4 | [:api_token, { |
| 5 | :placeholder => 'URL to receive a POST request when an error occurs', | 5 | :placeholder => 'URL to receive a POST request when an error occurs', |
| 6 | :label => 'URL' | 6 | :label => 'URL' |
| @@ -8,7 +8,7 @@ class NotificationServices::WebhookService < NotificationService | @@ -8,7 +8,7 @@ class NotificationServices::WebhookService < NotificationService | ||
| 8 | ] | 8 | ] |
| 9 | 9 | ||
| 10 | def check_params | 10 | def check_params |
| 11 | - if Fields.detect {|f| self[f[0]].blank? } | 11 | + if FIELDS.detect {|f| self[f[0]].blank? } |
| 12 | errors.add :base, 'You must specify the URL' | 12 | errors.add :base, 'You must specify the URL' |
| 13 | end | 13 | end |
| 14 | end | 14 | end |
app/views/apps/_service_notification_fields.html.haml
| @@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
| 14 | %div.notification_params.none{:class => (w.object && !(w.object.class < NotificationService)) ? 'chosen' : nil} | 14 | %div.notification_params.none{:class => (w.object && !(w.object.class < NotificationService)) ? 'chosen' : nil} |
| 15 | - NotificationService.subclasses.each do |notification_service| | 15 | - NotificationService.subclasses.each do |notification_service| |
| 16 | %div.notification_params{:class => (w.object.is_a?(notification_service) ? 'chosen ' : '') << notification_service.label} | 16 | %div.notification_params{:class => (w.object.is_a?(notification_service) ? 'chosen ' : '') << notification_service.label} |
| 17 | - - notification_service::Fields.each do |field, field_info| | 17 | + - notification_service::FIELDS.each do |field, field_info| |
| 18 | = w.label field, field_info[:label] || field.to_s.titleize | 18 | = w.label field, field_info[:label] || field.to_s.titleize |
| 19 | - field_type = field == :password ? :password_field : :text_field | 19 | - field_type = field == :password ? :password_field : :text_field |
| 20 | - value = field == :notify_at_notices ? w.object.notify_at_notices.join(", ") : w.object.send(field) | 20 | - value = field == :notify_at_notices ? w.object.notify_at_notices.join(", ") : w.object.send(field) |
spec/decorators/issue_tracker_type_decorator_spec.rb
| @@ -41,7 +41,7 @@ describe IssueTrackerDecorator do | @@ -41,7 +41,7 @@ describe IssueTrackerDecorator do | ||
| 41 | end | 41 | end |
| 42 | 42 | ||
| 43 | describe "#fields" do | 43 | describe "#fields" do |
| 44 | - it 'return all Fields define decorate' do | 44 | + it 'return all FIELDS define decorate' do |
| 45 | decorator.fields do |itf| | 45 | decorator.fields do |itf| |
| 46 | expect(itf).to be_a(IssueTrackerFieldDecorator) | 46 | expect(itf).to be_a(IssueTrackerFieldDecorator) |
| 47 | expect([:foo, :bar]).to be_include(itf.object) | 47 | expect([:foo, :bar]).to be_include(itf.object) |