Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubocop layout rules fix #9982

Closed
15 changes: 15 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,18 @@ Style/ParenthesesAroundCondition:

Style/PreferredHashMethods:
Enabled: false

Layout/SpaceAroundOperators:
Enabled: true

Layout/SpaceAroundMethodCallOperator:
Enabled: true

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true

Layout/EmptyLineBetweenDefs:
Enabled: true

Layout/FirstHashElementIndentation:
Enabled: false
2 changes: 1 addition & 1 deletion app/controllers/api/v2/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def check_media_type
def render_error(error, options = { })
options = set_error_details(error, options)
render options.merge(:template => "api/v2/errors/#{error}",
:layout => 'api/v2/layouts/error_layout')
:layout => 'api/v2/layouts/error_layout')
end
end
end
Expand Down
1 change: 1 addition & 0 deletions app/graphql/resolvers/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def association(association_name)
private

attr_reader :type

delegate :model_class, to: :type

def base_class
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/layout_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module LayoutHelper
def mount_react_app
react_component('ReactApp', {
layout: layout_data,
metadata: app_metadata,
toasts: toast_notifications_data,
})
layout: layout_data,
metadata: app_metadata,
toasts: toast_notifications_data,
})
end

def fetch_menus
Expand Down
18 changes: 9 additions & 9 deletions app/helpers/search_bar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ def mount_search_bar
}
url = send("auto_complete_search_#{auto_complete_controller_name}_path")
react_component("SearchBar", data: {
controller: auto_complete_controller_name,
autocomplete: {
id: 'searchBar',
searchQuery: params[:search],
url: url,
useKeyShortcuts: true,
},
bookmarks: bookmarks,
})
controller: auto_complete_controller_name,
autocomplete: {
id: 'searchBar',
searchQuery: params[:search],
url: url,
useKeyShortcuts: true,
},
bookmarks: bookmarks,
})
end
end
1 change: 1 addition & 0 deletions app/models/compute_resources/foreman/model/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Foreman::Model
class Openstack < ComputeResource
include KeyPairComputeResource
attr_accessor :scheduler_hint_value

delegate :flavors, :to => :client
delegate :security_groups, :to => :client

Expand Down
12 changes: 6 additions & 6 deletions app/models/compute_resources/foreman/model/vmware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,12 @@ def set_vm_volumes_attributes(vm, vm_attrs)
end

def build_vmrc_uri(host, vmid, ticket)
uri = URI::Generic.build(:scheme => 'vmrc',
:userinfo => "clone:#{ticket}",
:host => host,
:port => 443,
:path => '/',
:query => "moid=#{vmid}").to_s
uri = URI::Generic.build(:scheme => 'vmrc',
:userinfo => "clone:#{ticket}",
:host => host,
:port => 443,
:path => '/',
:query => "moid=#{vmid}").to_s
# VMRC doesn't like brackets around IPv6 addresses
uri.sub(/(.*)\[/, '\1').sub(/(.*)\]/, '\1')
end
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/destroy_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def being_destroyed?

included do
attr_accessor :_active_record_being_destroyed

before_destroy { |record| record._active_record_being_destroyed = true }
end
end
1 change: 1 addition & 0 deletions app/models/concerns/ensure_not_used_by.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TODO: it would deserve its own folder
class EnsureNotUsedBy
attr_reader :klasses

def initialize(*attribute)
@klasses = attribute
end
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/foreman/observable_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module ObservableModel

included do
attr_reader :preloaded_object

class_attribute :event_subscription_hooks
self.event_subscription_hooks ||= []
end
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/nested_ancestry_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def to_param

module ClassMethods
attr_reader :nested_attribute_fields

def nested_attribute_for(*fields)
@nested_attribute_fields = fields
@nested_attribute_fields.each do |field|
Expand Down
25 changes: 13 additions & 12 deletions app/models/concerns/orchestration/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Orchestration::Compute

included do
attr_accessor :compute_attributes, :vm

after_validation :validate_compute_provisioning, :queue_compute
before_destroy :queue_compute_destroy
end
Expand Down Expand Up @@ -61,17 +62,17 @@ def queue_compute

def queue_compute_create
if find_image.try(:user_data)
queue.create(:name => _("Render user data template for %s") % self, :priority => 2,
:action => [self, :setUserData])
queue.create(:name => _("Render user data template for %s") % self, :priority => 2,
:action => [self, :setUserData])
end
queue.create(:name => _("Set up compute instance %s") % self, :priority => 3,
:action => [self, :setCompute])
queue.create(:name => _("Set up compute instance %s") % self, :priority => 3,
:action => [self, :setCompute])
if compute_provides?(:ip) || compute_provides?(:ip6)
queue.create(:name => _("Acquire IP addresses for %s") % self, :priority => 4,
:action => [self, :setComputeIP])
queue.create(:name => _("Acquire IP addresses for %s") % self, :priority => 4,
:action => [self, :setComputeIP])
end
queue.create(:name => _("Query instance details for %s") % self, :priority => 5,
:action => [self, :setComputeDetails])
queue.create(:name => _("Query instance details for %s") % self, :priority => 5,
:action => [self, :setComputeDetails])
if compute_provides?(:mac) && (mac_based_ipam?(:subnet) || mac_based_ipam?(:subnet6))
queue.create(:name => _("Set IP addresses for %s") % self, :priority => 6,
:action => [self, :setComputeIPAM])
Expand All @@ -85,14 +86,14 @@ def queue_compute_create
def queue_compute_update
return unless compute_update_required?
logger.debug("Detected a change is required for compute resource")
queue.create(:name => _("Compute resource update for %s") % old, :priority => 7,
:action => [self, :setComputeUpdate])
queue.create(:name => _("Compute resource update for %s") % old, :priority => 7,
:action => [self, :setComputeUpdate])
end

def queue_compute_destroy
return unless errors.empty? && compute_resource_id.present? && uuid
queue.create(:name => _("Removing compute instance %s") % self, :priority => 100,
:action => [self, :delCompute])
queue.create(:name => _("Removing compute instance %s") % self, :priority => 100,
:action => [self, :delCompute])
end

def setCompute
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/orchestration/puppetca.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Orchestration::Puppetca

included do
attr_reader :puppetca

after_validation :initialize_puppetca, :unless => :skip_orchestration?
after_validation :queue_puppetca
before_destroy :initialize_puppetca, :queue_puppetca_destroy
Expand Down
1 change: 1 addition & 0 deletions app/models/personal_access_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PersonalAccessToken < ApplicationRecord
scope :inactive, -> { where(revoked: true).or(where("expires_at < ?", Time.current.utc)) }

attr_accessor :token_value

validate :expires_at_in_future
validate :valid_expires_at

Expand Down
1 change: 1 addition & 0 deletions app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Role < ApplicationRecord
before_destroy :check_deletable

attr_accessor :modify_locked

validate :not_locked
before_destroy :not_locked

Expand Down
1 change: 1 addition & 0 deletions app/models/template_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class TemplateInput < ApplicationRecord

class ValueNotReady < ::Foreman::Exception
end

class UnsatisfiedRequiredInput < ::Foreman::Exception
end

Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class User < ApplicationRecord

validates_lengths_from_database :except => [:firstname, :lastname, :format, :mail, :login]
attr_accessor :password_confirmation, :current_password

attribute :password

after_save :ensure_default_role
Expand Down
4 changes: 2 additions & 2 deletions app/models/usergroup_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def ensure_no_cycle
def add_new_cache
find_all_affected_users.each do |user|
find_all_user_roles.each do |user_role|
CachedUserRole.create!(:user => user, :role => user_role.role,
:user_role => user_role)
CachedUserRole.create!(:user => user, :role => user_role.role,
:user_role => user_role)
end

find_all_usergroups.each do |group|
Expand Down
1 change: 1 addition & 0 deletions app/presenters/host_status_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def initialize(status_class)
end

attr_reader :status_class

delegate :status_name, to: :status_class
alias_method :name, :status_name

Expand Down
2 changes: 1 addition & 1 deletion app/registries/foreman/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require_dependency 'foreman/plugin/medium_providers_registry'
require_dependency 'foreman/plugin/fact_importer_registry'

module Foreman #:nodoc:
module Foreman # :nodoc:
class PluginNotFound < Foreman::Exception; end
class PluginRequirementError < Foreman::Exception; end

Expand Down
1 change: 1 addition & 0 deletions app/registries/menu/toggle.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Menu
class Toggle < Node
attr_accessor :icon

def initialize(name, caption, icon)
@caption = caption
@icon = icon || ""
Expand Down
1 change: 1 addition & 0 deletions app/services/breadcrumbs_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def bar_props
delegate :logger, :to => :Rails
delegate :resource_name, :resource_class, :controller_path, :resource_path, :to => :controller
attr_reader :controller, :action_name, :page_header, :options

def index_item
begin
class_name = resource_class.to_s
Expand Down
1 change: 1 addition & 0 deletions app/services/classification/matches_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def self.matches(host, keys)
end

attr_reader :host, :keys

def initialize(host, keys)
@host = host
@keys = keys
Expand Down
1 change: 1 addition & 0 deletions app/services/foreman/renderer/base_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def self.render(source, scope)
private

attr_reader :source, :scope

delegate :name, :content, to: :source, prefix: true
end
end
Expand Down
1 change: 1 addition & 0 deletions app/services/host_build_status.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class HostBuildStatus
attr_reader :host, :state, :errors

delegate :available_template_kinds, :smart_proxies, :to => :host
VALIDATION_TYPES = [:host, :templates, :proxies]

Expand Down
1 change: 1 addition & 0 deletions app/services/oidc_jwt_validate.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class OidcJwtValidate
attr_reader :decoded_token

delegate :logger, to: :Rails

def initialize(jwt_token)
Expand Down
1 change: 1 addition & 0 deletions app/services/orchestration/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Orchestration
# Represents tasks queue for orchestration
class Queue
attr_reader :items, :name

STATUS = %w[pending running failed completed rollbacked conflict canceled]

delegate :count, :size, :empty?, :to => :items
Expand Down
16 changes: 8 additions & 8 deletions app/services/power_manager/bmc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def ready?
# TODO: consider moving this to the proxy code, so we can just delegate like as with Virt.
def action_map
super.deep_merge({
:start => 'on',
:stop => 'off',
:poweroff => 'off',
:reboot => 'soft',
:reset => 'cycle',
:state => 'status',
:ready? => 'ready?',
})
:start => 'on',
:stop => 'off',
:poweroff => 'off',
:reboot => 'soft',
:reset => 'cycle',
:state => 'status',
:ready? => 'ready?',
})
end

def default_action(action)
Expand Down
14 changes: 7 additions & 7 deletions app/services/power_manager/virt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ def default_action(action)

def action_map
super.deep_merge({
:on => 'start',
:off => 'stop',
:soft => 'reboot',
:cycle => 'reset',
:status => {:action => :virt_state, :output => :state_output},
:state => {:action => :virt_state, :output => :state_output},
})
:on => 'start',
:off => 'stop',
:soft => 'reboot',
:cycle => 'reset',
:status => {:action => :virt_state, :output => :state_output},
:state => {:action => :virt_state, :output => :state_output},
})
end

private
Expand Down
1 change: 1 addition & 0 deletions app/services/sso/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module SSO
class Base
attr_reader :controller
attr_accessor :user, :has_rendered

delegate :request, :to => :controller

OIDC_ACCESS_TOKEN = 'HTTP_OIDC_ACCESS_TOKEN'
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20090730152224_create_ptables.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class CreatePtables < ActiveRecord::Migration[4.2]
class Ptable < ApplicationRecord; end

def up
create_table :ptables do |t|
t.string :name, :limit => 64, :null => false
Expand Down
8 changes: 4 additions & 4 deletions db/seeds.d/035-admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
elsif User.unscoped.only_admin.except_hidden.none?
User.without_auditing do
User.as_anonymous_admin do
user = User.new(:login => admin_login,
:firstname => ENV['SEED_ADMIN_FIRST_NAME'] || "Admin",
:lastname => ENV['SEED_ADMIN_LAST_NAME'] || "User",
:mail => (ENV['SEED_ADMIN_EMAIL'] || Setting[:administrator]).try(:dup))
user = User.new(:login => admin_login,
:firstname => ENV['SEED_ADMIN_FIRST_NAME'] || "Admin",
:lastname => ENV['SEED_ADMIN_LAST_NAME'] || "User",
:mail => (ENV['SEED_ADMIN_EMAIL'] || Setting[:administrator]).try(:dup))
user.admin = true
user.auth_source = src_internal
user.locale = ENV['SEED_ADMIN_LOCALE'] if ENV['SEED_ADMIN_LOCALE'].present?
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/audits.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TRANSLATORS: do not translate
desc <<~END_DESC
Expire or anonymize old audits automatically.
Expire or anonymize old audits automatically.#{' '}
The number of days can be easily defined in Settings or you can use "days" parameter.
If both Setting and parameter are undefined, task finishes without cleaning any audits.
Template audits are left uncleaned.
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/convert.rake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ namespace :db do
self.inheritance_column = :_type_disabled
extend ClassWorkarounds
end

class DevelopmentModelClass < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
# disable STI
self.inheritance_column = :_type_disabled
Expand Down
Loading
Loading