diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 75a4275..e91782a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -96,20 +96,6 @@ Style/ClassAndModuleChildren: - 'app/models/notification_services/webhook_service.rb' - 'config/initializers/overrides.rb' -# Offense count: 23 -Style/ConstantName: - Exclude: - - 'app/models/notification_service.rb' - - 'app/models/notification_services/campfire_service.rb' - - 'app/models/notification_services/flowdock_service.rb' - - 'app/models/notification_services/gtalk_service.rb' - - 'app/models/notification_services/hipchat_service.rb' - - 'app/models/notification_services/hoiio_service.rb' - - 'app/models/notification_services/hubot_service.rb' - - 'app/models/notification_services/pushover_service.rb' - - 'app/models/notification_services/slack_service.rb' - - 'app/models/notification_services/webhook_service.rb' - # Offense count: 70 # Configuration parameters: Exclude. Style/Documentation: diff --git a/app/models/notification_service.rb b/app/models/notification_service.rb index 1ef6cb2..8cb3877 100644 --- a/app/models/notification_service.rb +++ b/app/models/notification_service.rb @@ -18,13 +18,13 @@ class NotificationService validate :check_params if Errbit::Config.per_app_notify_at_notices - Fields = [[:notify_at_notices, + FIELDS = [[:notify_at_notices, { :placeholder => 'comma separated numbers or simply 0 for every notice', :label => 'notify on errors (0 for all errors)' } ]] else - Fields = [] + FIELDS = [] end def notify_at_notices @@ -54,9 +54,9 @@ class NotificationService end # Retrieve tracker label from either class or instance. - Label = '' + LABEL = '' def self.label - self::Label + self::LABEL end def label diff --git a/app/models/notification_services/campfire_service.rb b/app/models/notification_services/campfire_service.rb index 3886f9c..f6a2922 100644 --- a/app/models/notification_services/campfire_service.rb +++ b/app/models/notification_services/campfire_service.rb @@ -1,7 +1,7 @@ if defined? Campy class NotificationServices::CampfireService < NotificationService - Label = "campfire" - Fields += [ + LABEL = "campfire" + FIELDS += [ [:subdomain, { :label => "Subdomain", :placeholder => "subdomain from http://{{subdomain}}.campfirenow.com" @@ -17,7 +17,7 @@ if defined? Campy ] def check_params - if Fields.detect {|f| self[f[0]].blank? } + if FIELDS.detect {|f| self[f[0]].blank? } errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID' end end diff --git a/app/models/notification_services/flowdock_service.rb b/app/models/notification_services/flowdock_service.rb index da2dfe8..524997a 100644 --- a/app/models/notification_services/flowdock_service.rb +++ b/app/models/notification_services/flowdock_service.rb @@ -1,7 +1,7 @@ if defined? Flowdock class NotificationServices::FlowdockService < NotificationService - Label = 'flowdock' - Fields += [ + LABEL = 'flowdock' + FIELDS += [ [ :api_token, { :label => 'Flow API Token', @@ -11,7 +11,7 @@ if defined? Flowdock ] def check_params - if Fields.any? { |f, _| self[f].blank? } + if FIELDS.any? { |f, _| self[f].blank? } errors.add :base, 'You must specify your Flowdock(Flow) API token' end end diff --git a/app/models/notification_services/gtalk_service.rb b/app/models/notification_services/gtalk_service.rb index 9241abd..c9966e5 100644 --- a/app/models/notification_services/gtalk_service.rb +++ b/app/models/notification_services/gtalk_service.rb @@ -1,6 +1,6 @@ class NotificationServices::GtalkService < NotificationService - Label = "gtalk" - Fields += [ + LABEL = "gtalk" + FIELDS += [ [:subdomain, { :placeholder => "username@example.com", :label => "Username" @@ -28,7 +28,7 @@ class NotificationServices::GtalkService < NotificationService ] def check_params - if Fields.detect { |f| self[f[0]].blank? && self[f[2]].blank? } + if FIELDS.detect { |f| self[f[0]].blank? && self[f[2]].blank? } errors.add :base, """You must specify your Username, Password, service, service_url and either rooms or users to send to or both""" diff --git a/app/models/notification_services/hipchat_service.rb b/app/models/notification_services/hipchat_service.rb index 987b9ca..4852c7f 100644 --- a/app/models/notification_services/hipchat_service.rb +++ b/app/models/notification_services/hipchat_service.rb @@ -1,7 +1,7 @@ if defined? HipChat class NotificationServices::HipchatService < NotificationService - Label = 'hipchat' - Fields += [ + LABEL = 'hipchat' + FIELDS += [ [:service, { :placeholder => "'v1' (admin API token) or 'v2' (account API token)", :label => "HipChat API version" @@ -19,17 +19,17 @@ if defined? HipChat :label => "Room name" }] ] - Mandatory_fields = [:service, :api_token, :room_id] - API_versions = %w(v1 v2) + MANDATORY_FIELDS = [:service, :api_token, :room_id] + API_VERSIONS = %w(v1 v2) def check_params - Fields.each do |field, hash| - if Mandatory_fields.include?(field) && self[field].blank? + FIELDS.each do |field, hash| + if MANDATORY_FIELDS.include?(field) && self[field].blank? errors.add field, "You must specify #{hash[:label]}" end end - unless API_versions.include?(self[:service]) - errors.add :service, "API version must be #{API_versions.join(' or ')}" + unless API_VERSIONS.include?(self[:service]) + errors.add :service, "API version must be #{API_VERSIONS.join(' or ')}" end end diff --git a/app/models/notification_services/hoiio_service.rb b/app/models/notification_services/hoiio_service.rb index 3106c71..72b614d 100644 --- a/app/models/notification_services/hoiio_service.rb +++ b/app/models/notification_services/hoiio_service.rb @@ -1,6 +1,6 @@ class NotificationServices::HoiioService < NotificationService - Label = "hoiio" - Fields += [ + LABEL = "hoiio" + FIELDS += [ [:api_token, { :placeholder => "App ID", :label => "App ID" @@ -16,7 +16,7 @@ class NotificationServices::HoiioService < NotificationService ] def check_params - if Fields.detect {|f| self[f[0]].blank? } + if FIELDS.detect {|f| self[f[0]].blank? } errors.add :base, 'You must specify your App ID, Access Token and Recipient\'s phone numbers' end end diff --git a/app/models/notification_services/hubot_service.rb b/app/models/notification_services/hubot_service.rb index cc0f944..13b9d48 100644 --- a/app/models/notification_services/hubot_service.rb +++ b/app/models/notification_services/hubot_service.rb @@ -1,6 +1,6 @@ class NotificationServices::HubotService < NotificationService - Label = "hubot" - Fields += [ + LABEL = "hubot" + FIELDS += [ [:api_token, { :placeholder => 'http://hubot.example.org:8080/hubot/say', :label => 'Hubot URL' @@ -12,7 +12,7 @@ class NotificationServices::HubotService < NotificationService ] def check_params - if Fields.detect {|f| self[f[0]].blank? } + if FIELDS.detect {|f| self[f[0]].blank? } errors.add :base, 'You must specify the URL of your hubot' end end diff --git a/app/models/notification_services/pushover_service.rb b/app/models/notification_services/pushover_service.rb index a1867f9..b0a7d8b 100644 --- a/app/models/notification_services/pushover_service.rb +++ b/app/models/notification_services/pushover_service.rb @@ -1,6 +1,6 @@ class NotificationServices::PushoverService < NotificationService - Label = "pushover" - Fields += [ + LABEL = "pushover" + FIELDS += [ [:api_token, { :placeholder => "User Key", :label => "User Key" @@ -12,7 +12,7 @@ class NotificationServices::PushoverService < NotificationService ] def check_params - if Fields.detect {|f| self[f[0]].blank? } + if FIELDS.detect {|f| self[f[0]].blank? } errors.add :base, 'You must specify your User Key and Application API Token.' end end diff --git a/app/models/notification_services/slack_service.rb b/app/models/notification_services/slack_service.rb index f16457b..95a33f4 100644 --- a/app/models/notification_services/slack_service.rb +++ b/app/models/notification_services/slack_service.rb @@ -1,6 +1,6 @@ class NotificationServices::SlackService < NotificationService - Label = "slack" - Fields += [ + LABEL = "slack" + FIELDS += [ [:service_url, { :placeholder => 'Slack Hook URL (https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXX)', :label => 'Hook URL' @@ -8,7 +8,7 @@ class NotificationServices::SlackService < NotificationService ] def check_params - if Fields.detect {|f| self[f[0]].blank? } + if FIELDS.detect {|f| self[f[0]].blank? } errors.add :base, "You must specify your Slack Hook url." end end diff --git a/app/models/notification_services/webhook_service.rb b/app/models/notification_services/webhook_service.rb index 6d5b999..4225026 100644 --- a/app/models/notification_services/webhook_service.rb +++ b/app/models/notification_services/webhook_service.rb @@ -1,6 +1,6 @@ class NotificationServices::WebhookService < NotificationService - Label = "webhook" - Fields = [ + LABEL = "webhook" + FIELDS = [ [:api_token, { :placeholder => 'URL to receive a POST request when an error occurs', :label => 'URL' @@ -8,7 +8,7 @@ class NotificationServices::WebhookService < NotificationService ] def check_params - if Fields.detect {|f| self[f[0]].blank? } + if FIELDS.detect {|f| self[f[0]].blank? } errors.add :base, 'You must specify the URL' end end diff --git a/app/views/apps/_service_notification_fields.html.haml b/app/views/apps/_service_notification_fields.html.haml index 430a252..5b61fb5 100644 --- a/app/views/apps/_service_notification_fields.html.haml +++ b/app/views/apps/_service_notification_fields.html.haml @@ -14,7 +14,7 @@ %div.notification_params.none{:class => (w.object && !(w.object.class < NotificationService)) ? 'chosen' : nil} - NotificationService.subclasses.each do |notification_service| %div.notification_params{:class => (w.object.is_a?(notification_service) ? 'chosen ' : '') << notification_service.label} - - notification_service::Fields.each do |field, field_info| + - notification_service::FIELDS.each do |field, field_info| = w.label field, field_info[:label] || field.to_s.titleize - field_type = field == :password ? :password_field : :text_field - value = field == :notify_at_notices ? w.object.notify_at_notices.join(", ") : w.object.send(field) diff --git a/spec/decorators/issue_tracker_type_decorator_spec.rb b/spec/decorators/issue_tracker_type_decorator_spec.rb index f45e604..1f49363 100644 --- a/spec/decorators/issue_tracker_type_decorator_spec.rb +++ b/spec/decorators/issue_tracker_type_decorator_spec.rb @@ -41,7 +41,7 @@ describe IssueTrackerDecorator do end describe "#fields" do - it 'return all Fields define decorate' do + it 'return all FIELDS define decorate' do decorator.fields do |itf| expect(itf).to be_a(IssueTrackerFieldDecorator) expect([:foo, :bar]).to be_include(itf.object) -- libgit2 0.21.2