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

[update] rubocop 1.18.4 #4165

Closed
wants to merge 45 commits into from
Closed

[update] rubocop 1.18.4 #4165

wants to merge 45 commits into from

Conversation

itowtips
Copy link
Contributor

@itowtips itowtips commented Oct 5, 2021

No description provided.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

rubocop

app/models/concerns/ss/addon/generate_lock.rb|30 col 131| Layout/LineLength: Line is too long. [184/130]
app/models/concerns/ss/model/user.rb|104 col 7| [Correctable] Style/CaseLikeIf: Convert if-elsif to case-when.
app/models/concerns/sys/ad.rb|16 col 30| [Correctable] Rails/ActiveRecordAliases: Use update instead of update_attributes.
app/models/gws/history.rb|106 col 131| Layout/LineLength: Line is too long. [146/130]
app/models/gws/monitor/topic.rb|35 col 3| [Correctable] Rails/ActiveRecordCallbacksOrder: after_validation is supposed to appear before around_destroy.
app/models/gws/monitor/topic.rb|138 col 7| [Correctable] Style/NegatedIfElseCondition: Invert the negated condition and swap the if-else branches.
app/models/sys/auth/open_id_connect/token_response.rb|4 col 131| [Correctable] Layout/LineLength: Line is too long. [161/130]
app/models/webmail/history.rb|108 col 131| Layout/LineLength: Line is too long. [133/130]
app/views/gws/presence/apis/users/index.json.jbuilder|8 col 31| [Correctable] Style/NestedParenthesizedCalls: Add parentheses to nested method call user_presence.label :state.
app/views/gws/presence/apis/users/show.json.jbuilder|8 col 31| [Correctable] Style/NestedParenthesizedCalls: Add parentheses to nested method call user_presence.label :state.
db/seeds/cms/contents/forms.rb|178 col 131| [Correctable] Layout/LineLength: Line is too long. [134/130]
db/seeds/cms/contents/forms.rb|179 col 131| [Correctable] Layout/LineLength: Line is too long. [141/130]
lib/tasks/ss/deploy.rake|8 col 7| Lint/DuplicateBranch: Duplicate branch body detected.
lib/tasks/voice/synthesis.rake|10 col 41| [Correctable] Style/IfWithBooleanLiteralBranches: Remove redundant ternary operator with boolean literal branches.
lib/translate/convertor.rb|13 col 31| [Correctable] Lint/UriRegexp: URI::regexp(%w(http https)) is obsolete and should not be used. Instead, use URI::DEFAULT_PARSER.make_regexp(%w(http https)).
spec/features/cms/agents/nodes/group_page_spec.rb|68 col 131| [Correctable] Layout/LineLength: Line is too long. [162/130]
spec/jobs/article/page/import_job_spec.rb|406 col 131| [Correctable] Layout/LineLength: Line is too long. [152/130]
spec/models/gws/system/menu_setting_spec.rb|154 col 7| Rails/I18nLocaleAssignment: Use I18n.with_locale with block instead of I18n.locale=.

if !Article::Page::Importer.valid_encoding?(file.to_io, Encoding::SJIS)
raise I18n.t("errors.messages.unsupported_encoding")
end
if !Article::Page::Importer.valid_encoding?(file.to_io, Encoding::UTF_8) && !Article::Page::Importer.valid_encoding?(file.to_io, Encoding::SJIS)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Layout/LineLength: Line is too long. [150/130]

render_url = "#{@cur_site.full_url}#{archive_path}"

if preview_path?
render_url = "#{cms_preview_path(site: @cur_site, path: @cur_main_path[1..-1].sub('/index.html', ''))}/#{Time.zone.now.strftime('%Y%m')}"
render_url = "#{cms_preview_path(site: @cur_site, path: @cur_main_path[1..].sub('/index.html', ''))}/#{Time.zone.now.strftime('%Y%m')}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Layout/LineLength: Line is too long. [141/130]

@@ -30,11 +30,11 @@ def set_manageable
if Gws::UserPresence.allowed?(:manage_all, @cur_user, site: @cur_site)
@manageable = true
end
if Gws::UserPresence.allowed?(:manage_private, @cur_user, site: @cur_site)
@manageable = true if @group && (@group.id == @cur_user.gws_default_group.id)
if Gws::UserPresence.allowed?(:manage_private, @cur_user, site: @cur_site) && (@group && (@group.id == @cur_user.gws_default_group.id))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Layout/LineLength: Line is too long. [139/130]

@@ -45,9 +45,9 @@ def group_list
group_list << {id: group.id, state: group.state, name: group.name, order: group.order, packages: datasets.count}
end

if sort =~ /^name$/i
if /^name$/i.match?(sort)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Style/CaseLikeIf: Convert if-elsif to case-when.

@@ -31,13 +31,13 @@ def resource_search_check(queries, order_by, offset, limit)
end

def convert_property_name(field)
if field =~ /^name$/i
if /^name$/i.match?(field)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Style/CaseLikeIf: Convert if-elsif to case-when.

if link_label.length > column.label_max_length
self.errors.add(:link_label, :too_long, count: column.label_max_length)
end
if link_label.present? && column.label_max_length.present? && column.label_max_length > 0 && (link_label.length > column.label_max_length)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Layout/LineLength: Line is too long. [142/130]

if link_url.length > column.link_max_length
self.errors.add(:link_url, :too_long, count: column.link_max_length)
end
if link_url.present? && column.link_max_length.present? && column.link_max_length > 0 && (link_url.length > column.link_max_length)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Layout/LineLength: Line is too long. [135/130]

when "gws/faq/topic", "gws/faq/post" then 'faq'
when "gws/qna/topic", "gws/qna/post" then 'qna'
when "gws/schedule/todo" then 'todo'
when "gws/schedule/todo_comment" then 'todo'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [rubocop] reported by reviewdog 🐶
Lint/DuplicateBranch: Duplicate branch body detected.

if dependant_scope.where(name: self.name).present? && dependant_scope.where(id: self.id).first.name != self.name
errors.add :base, :not_move_to_same_name_folder
end
if self.id != 0 && (dependant_scope.where(name: self.name).present? && dependant_scope.where(id: self.id).first.name != self.name)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Layout/LineLength: Line is too long. [134/130]

@@ -14,11 +14,11 @@ def each_areas(&block)
kind_code = kind.elements['Code'].text.to_s.strip
kind_status = kind.elements['Status'].text.to_s.strip

if kind_name =~ /特別警報/
if /特別警報/.match?(kind_name)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Style/CaseLikeIf: Convert if-elsif to case-when.

if generate_lock_until > Time.zone.now + SS::Duration.parse(SS.config.cms.generate_lock['generate_lock_until'])
errors.add :generate_lock_until, :disallow_datetime_by_system
end
if SS.config.cms.generate_lock['generate_lock_until'].present? && (generate_lock_until > Time.zone.now + SS::Duration.parse(SS.config.cms.generate_lock['generate_lock_until']))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Layout/LineLength: Line is too long. [184/130]

@@ -101,9 +101,9 @@ module SS::Model::User

module ClassMethods
def flex_find(keyword)
if keyword =~ /^\d+$/
if /^\d+$/.match?(keyword)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Style/CaseLikeIf: Convert if-elsif to case-when.

@@ -13,6 +13,6 @@ module Sys::Ad
private

def file_state_update
files.each {|file| file.update_attributes(state: "public")}
files.each { |file| file.update_attributes(state: "public") }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [rubocop] reported by reviewdog 🐶
[Correctable] Rails/ActiveRecordAliases: Use update instead of update_attributes.

if severity_to_num(severity) >= severity_to_num(allowed_severity)
item.save!(context: context.to_sym)
end
if allowed_severity = cur_site.allowed_log_severity_for(item.module_key) && (severity_to_num(severity) >= severity_to_num(allowed_severity))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Layout/LineLength: Line is too long. [146/130]

around_destroy ::Gws::Elasticsearch::Indexer::MonitorTopicJob.callback

#validates :category_ids, presence: true
after_validation :set_descendants_updated_with_released, if: -> { released.present? && released_changed? }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Rails/ActiveRecordCallbacksOrder: after_validation is supposed to appear before around_destroy.

@@ -7,7 +7,7 @@ namespace :voice do
task synthesis: [:environment, :setup_logger] do
id_or_url = ENV["id"] || ENV["url"]
force = ENV["force"] || "false"
force = force =~ /^(false|0)$/i ? false : true
force = /^(false|0)$/i.match?(force) ? false : true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Style/IfWithBooleanLiteralBranches: Remove redundant ternary operator with boolean literal branches.

return false if text =~ /\A#{URI::regexp(%w(http https))}\z/
return false if text =~ /\A[#{I18n.t("translate.ignore_character")}]+\z/
return false if EmailValidator::REGEXP.match?(text)
return false if /\A#{URI::regexp(%w(http https))}\z/.match?(text)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [rubocop] reported by reviewdog 🐶
[Correctable] Lint/UriRegexp: URI::regexp(%w(http https)) is obsolete and should not be used. Instead, use URI::DEFAULT_PARSER.make_regexp(%w(http https)).

let! (:child_loop_html) { '<li><a href="#{url}">#{index_name}</a></li>' }
let! (:child_lower_html) { '</ul>' }
let!(:upper_html) { '<div class="middle dw">' }
let!(:loop_html) { '<section class="item dw-panel"><div class="dw-panel__content"><h2><a href="#{url}">#{index_name}</a></h2>#{child_items}</div></section>' }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Layout/LineLength: Line is too long. [162/130]

expect(page3.category_ids).to match_array [cate2_3.id]
expect(page4.category_ids).to match_array [cate2_2.id, cate1_4.id]
expect(page1.category_ids).to match_array [cate1_depth3.id, cate2_depth3.id]
expect(page2.category_ids).to match_array [cate1_depth3.id, cate2_depth3.id, cate1_depth2.id, cate2_depth2.id, cate1_depth1.id, cate2_depth1.id]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Layout/LineLength: Line is too long. [152/130]

@@ -151,7 +151,7 @@

it do
I18n.enforce_available_locales = false
I18n.locale = 'zh-TW'.to_sym
I18n.locale = :'zh-TW'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Rails/I18nLocaleAssignment: Use I18n.with_locale with block instead of I18n.locale=.

@@ -74,7 +74,7 @@ def normalize_name
def validate_name
return if name.blank?
# symbols is not allowed.
errors.add :name, :invalid if name =~ /[\x00-,:-@\[-\^`\{-\x7f]/
errors.add :name, :invalid if name =~ /[\x00-,:-@\[-\^`{-\x7f]/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.

@@ -67,9 +60,9 @@ def extract_datasets

def format_data(data)
return "-" if data.blank?
return data if data !~ /^(\-)?((\d)+\,)?((\d)+\.)?+(\d)+$/
return data if data !~ /^(-)?((\d)+,)?((\d)+\.)?+(\d)+$/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Performance/RegexpMatch: Use match? instead of !~ when MatchData is not used.

@@ -85,12 +85,12 @@ def gsub_img!
name = src_attr["alt"].presence || src_attr["title"].presence || href.sub(/.*\//, "")
cls = "tag-img" + ( src_attr["class"] ? " #{src_attr['class']}" : "" )

if href =~ /^\/fs\/.+?\/\_\/.+?#{ext}/
if href =~ /^\/fs\/.+?\/_\/.+?#{ext}/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.

@@ -58,7 +58,7 @@ def index
def create
@item = @model.new get_params
if @cur_node.captcha_enabled? && get_captcha[:captcha_error].nil?
unless is_captcha_valid?(@item)
unless captcha_valid?(@item)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer if conditions.

@@ -75,7 +75,7 @@ def new_reply
def reply
@item = @model.new get_params
if @cur_node.captcha_enabled? && get_captcha[:captcha_error].nil?
unless is_captcha_valid?(@item)
unless captcha_valid?(@item)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer if conditions.

@@ -119,7 +119,7 @@ def create
end

if @cur_node.captcha_enabled? && get_captcha[:captcha_error].nil?
unless is_captcha_valid?(@answer)
unless captcha_valid?(@answer)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer if conditions.

@coveralls
Copy link

coveralls commented Oct 5, 2021

Coverage Status

Coverage decreased (-0.04%) to 84.576% when pulling d174027 on fix-rubocop-issues into 617308b on master.

@sunny4381
Copy link
Member

@itowtips
Rails::ReflectionClassName が app/models/concerns/ss/relation/file.rb や app/models/concerns/workflow/addon/branch.rb で false positive になりますが、
Rubocop をバージョンアップしても、改善されていないなら Rails::ReflectionClassName を無効にして欲しいです。

参考: rubocop/rubocop-rails#106

@itowtips
Copy link
Contributor Author

itowtips commented Nov 4, 2021

リベース #4227

@itowtips itowtips closed this Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants