1
0
Fork 0

Full rubocop run (safe only)

Dieser Commit ist enthalten in:
angusmcleod 2021-02-24 18:50:42 +11:00
Ursprung 6f977049fc
Commit 484bd464d2
83 geänderte Dateien mit 985 neuen und 988 gelöschten Zeilen

Datei anzeigen

@ -85,7 +85,7 @@ class CustomWizard::AdminApiController < CustomWizard::AdminController
CustomWizard::Api::Authorization.set(params[:name], code: params[:code])
CustomWizard::Api::Authorization.get_token(params[:name])
return redirect_to path('/admin/wizards/apis/' + params[:name])
redirect_to path('/admin/wizards/apis/' + params[:name])
end
private

Datei anzeigen

@ -465,7 +465,6 @@ class CustomWizard::Action
name = keyArr.first
end
registered = registered_fields.select { |f| f[:name] == name }
if registered.first.present?
klass = registered.first[:klass]

Datei anzeigen

@ -4,7 +4,7 @@ class CustomWizard::Api
attr_accessor :name,
:title
def initialize(name, data={})
def initialize(name, data = {})
@name = name
data.each do |k, v|
self.send "#{k}=", v if self.respond_to?(k)

Datei anzeigen

@ -19,7 +19,7 @@ class CustomWizard::Api::Authorization
:username,
:password
def initialize(api_name, data={})
def initialize(api_name, data = {})
@api_name = api_name
data.each do |k, v|
@ -106,18 +106,18 @@ class CustomWizard::Api::Authorization
connection = Excon.new(
authorization.token_url,
:headers => {
headers: {
"Content-Type" => "application/x-www-form-urlencoded"
},
:method => 'GET',
:query => URI.encode_www_form(body)
method: 'GET',
query: URI.encode_www_form(body)
)
begin
result = connection.request()
log_params = {time: Time.now, user_id: 0, status: 'SUCCESS', url: authorization.token_url, error: ""}
log_params = { time: Time.now, user_id: 0, status: 'SUCCESS', url: authorization.token_url, error: "" }
CustomWizard::Api::LogEntry.set(name, log_params)
rescue SystemCallError => e
log_params = {time: Time.now, user_id: 0, status: 'FAILURE', url: authorization.token_url, error: "Token refresh request failed: #{e.inspect}"}
log_params = { time: Time.now, user_id: 0, status: 'FAILURE', url: authorization.token_url, error: "Token refresh request failed: #{e.inspect}" }
CustomWizard::Api::LogEntry.set(name, log_params)
end

Datei anzeigen

@ -9,7 +9,7 @@ class CustomWizard::Api::Endpoint
:content_type,
:success_codes
def initialize(api_name, data={})
def initialize(api_name, data = {})
@api_name = api_name
data.each do |k, v|
@ -35,7 +35,7 @@ class CustomWizard::Api::Endpoint
self.get(api_name, endpoint_id)
end
def self.get(api_name, endpoint_id, opts={})
def self.get(api_name, endpoint_id, opts = {})
return nil if !endpoint_id
if data = PluginStore.get("custom_wizard_api_#{api_name}", "endpoint_#{endpoint_id}")

Datei anzeigen

@ -12,7 +12,7 @@ class CustomWizard::Api::LogEntry
:name,
:avatar_template
def initialize(api_name, data={})
def initialize(api_name, data = {})
@api_name = api_name
data.each do |k, v|
@ -38,7 +38,7 @@ class CustomWizard::Api::LogEntry
self.get(api_name, log_id)
end
def self.get(api_name, log_id, opts={})
def self.get(api_name, log_id, opts = {})
return nil if !log_id
if data = PluginStore.get("custom_wizard_api_#{api_name}", "log_#{log_id}")

Datei anzeigen

@ -1,7 +1,7 @@
class CustomWizard::Builder
attr_accessor :wizard, :updater, :submissions
def initialize(wizard_id, user=nil)
def initialize(wizard_id, user = nil)
template = CustomWizard::Template.find(wizard_id)
return nil if template.blank?
@ -125,7 +125,7 @@ class CustomWizard::Builder
if final_step
if @wizard.id == @wizard.user.custom_fields['redirect_to_wizard']
@wizard.user.custom_fields.delete('redirect_to_wizard');
@wizard.user.custom_fields.delete('redirect_to_wizard')
@wizard.user.save_custom_fields(true)
end

Datei anzeigen

@ -90,7 +90,6 @@ class ::CustomWizard::CustomField
add_error(I18n.t("#{i18n_key}.unsupported_type", type: value))
end
if attr == 'name'
unless value.is_a?(String)
add_error(I18n.t("#{i18n_key}.name_invalid", name: value))

Datei anzeigen

@ -64,7 +64,7 @@ class CustomWizard::Field
@require_assets ||= {}
end
def self.register(type, plugin = nil, asset_paths = [], opts={})
def self.register(type, plugin = nil, asset_paths = [], opts = {})
if type
types[type.to_sym] ||= {}
types[type.to_sym] = opts[:type_opts] if opts[:type_opts].present?

Datei anzeigen

@ -212,7 +212,7 @@ class CustomWizard::Mapper
end
end
def interpolate(string, opts={ user: true, wizard: true, value: true })
def interpolate(string, opts = { user: true, wizard: true, value: true })
return string if string.blank?
if opts[:user]

Datei anzeigen

@ -10,7 +10,7 @@ class CustomWizard::Template
@data = data
end
def save(opts={})
def save(opts = {})
@opts = opts
normalize_data
@ -27,7 +27,7 @@ class CustomWizard::Template
@data[:id]
end
def self.save(data, opts={})
def self.save(data, opts = {})
new(data).save(opts)
end

Datei anzeigen

@ -2,7 +2,7 @@ class CustomWizard::TemplateValidator
include HasErrors
include ActiveModel::Model
def initialize(data, opts={})
def initialize(data, opts = {})
@data = data
@opts = opts
end

Datei anzeigen

@ -29,7 +29,7 @@ class CustomWizard::Wizard
:user,
:first_step
def initialize(attrs = {}, user=nil)
def initialize(attrs = {}, user = nil)
@user = user
attrs = attrs.with_indifferent_access
@ -177,7 +177,7 @@ class CustomWizard::Wizard
def can_access?
return false unless user
return true if user.admin
return permitted? && (multiple_submissions || !completed?)
permitted? && (multiple_submissions || !completed?)
end
def reset

Datei anzeigen

@ -137,7 +137,7 @@ after_initialize do
@excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/']
url = request.referer || request.original_url
if request.format === 'text/html' && !@excluded_routes.any? {|str| /#{str}/ =~ url} && wizard_id
if request.format === 'text/html' && !@excluded_routes.any? { |str| /#{str}/ =~ url } && wizard_id
if request.referer !~ /\/w\// && request.referer !~ /\/invites\//
CustomWizard::Wizard.set_submission_redirect(current_user, wizard_id, request.referer)
end
@ -153,7 +153,7 @@ after_initialize do
add_to_serializer(:site, :complete_custom_wizard) do
if scope.user && requires_completion = CustomWizard::Wizard.prompt_completion(scope.user)
requires_completion.map {|w| { name: w[:name], url: "/w/#{w[:id]}"} }
requires_completion.map { |w| { name: w[:name], url: "/w/#{w[:id]}" } }
end
end

Datei anzeigen

@ -4,8 +4,8 @@ require_relative '../../plugin_helper.rb'
describe CustomWizard::Cache do
it "writes and reads values to the cache" do
CustomWizard::Cache.new('list').write([1,2,3])
expect(CustomWizard::Cache.new('list').read).to eq([1,2,3])
CustomWizard::Cache.new('list').write([1, 2, 3])
expect(CustomWizard::Cache.new('list').read).to eq([1, 2, 3])
end
it "deletes values from the cache" do
@ -15,7 +15,7 @@ describe CustomWizard::Cache do
describe "#wrap" do
before do
@raw = [1,2,3]
@raw = [1, 2, 3]
end
def list
@ -23,12 +23,12 @@ describe CustomWizard::Cache do
end
it "returns value from passed block" do
expect(list).to eq([1,2,3])
expect(list).to eq([1, 2, 3])
end
it "returns cached value" do
cached = list
@raw = [3,2,1]
@raw = [3, 2, 1]
expect(list).to eq(cached)
end
end

Datei anzeigen

@ -23,7 +23,7 @@ describe CustomWizard::CustomField do
plugin_name = '#{CustomWizard::CustomField::NAMESPACE}' AND
key = '#{custom_field.name}' AND
value::jsonb = '#{field_json.except('name').to_json}'::jsonb
", ).exists?
",).exists?
).to eq(true)
end
end
@ -44,7 +44,7 @@ describe CustomWizard::CustomField do
plugin_name = '#{CustomWizard::CustomField::NAMESPACE}' AND
key = '#{updated_field.name}' AND
value::jsonb = '#{updated_field_json.except('name').to_json}'::jsonb
", ).exists?
",).exists?
).to eq(true)
end

Datei anzeigen

@ -2,8 +2,8 @@ require_relative '../../plugin_helper'
describe CustomWizard::Wizard do
fab!(:user) { Fabricate(:user) }
fab!(:trusted_user) { Fabricate(:user, trust_level: TrustLevel[3])}
fab!(:admin_user) { Fabricate(:user, admin: true)}
fab!(:trusted_user) { Fabricate(:user, trust_level: TrustLevel[3]) }
fab!(:admin_user) { Fabricate(:user, admin: true) }
let(:template_json) {
JSON.parse(File.open(

Datei anzeigen

@ -32,6 +32,6 @@ describe Jobs::SetAfterTimeWizard do
).to eq(3)
expect(messages.first.data).to eq("super_mega_fun_wizard")
expect(messages.first.user_ids).to match_array([user1.id,user2.id,user3.id])
expect(messages.first.user_ids).to match_array([user1.id, user2.id, user3.id])
end
end

Datei anzeigen

@ -53,7 +53,7 @@ describe CustomWizard::AdminManagerController do
expect(response.status).to eq(200)
expect(response.parsed_body['imported']).to match_array(templates)
expect(CustomWizard::Template.list.map {|t| t.slice('id', 'name') }).to match_array(templates)
expect(CustomWizard::Template.list.map { |t| t.slice('id', 'name') }).to match_array(templates)
end
it 'rejects a template with the same id as a saved template' do

Datei anzeigen

@ -1,9 +1,9 @@
require_relative '../../../plugin_helper'
describe CustomWizard::AdminSubmissionsController do
fab!(:admin_user) {Fabricate(:user, admin: true)}
fab!(:user1) {Fabricate(:user)}
fab!(:user2) {Fabricate(:user)}
fab!(:admin_user) { Fabricate(:user, admin: true) }
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
let(:template) {
JSON.parse(File.open(

Datei anzeigen

@ -1,9 +1,9 @@
require_relative '../../../plugin_helper'
describe CustomWizard::AdminWizardController do
fab!(:admin_user) {Fabricate(:user, admin: true)}
fab!(:user1) {Fabricate(:user)}
fab!(:user2) {Fabricate(:user)}
fab!(:admin_user) { Fabricate(:user, admin: true) }
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
let(:template) {
JSON.parse(File.open(

Datei anzeigen

@ -92,4 +92,3 @@ describe "custom field extensions" do
end
end
end

Datei anzeigen

@ -24,6 +24,6 @@ describe CustomWizard::CustomFieldSerializer do
expect(json[:name]).to eq("topic_field_1")
expect(json[:klass]).to eq("topic")
expect(json[:type]).to eq("boolean")
expect(json[:serializers]).to match_array(["topic_list_item","topic_view"])
expect(json[:serializers]).to match_array(["topic_list_item", "topic_view"])
end
end