Skip to content

Commit c04b018

Browse files
committed
Rubocop fixes
1 parent 1005d44 commit c04b018

File tree

7 files changed

+32
-24
lines changed

7 files changed

+32
-24
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AllCops:
1414

1515
Layout/MultilineMethodCallIndentation:
1616
Enabled: true
17-
EnforcedStyle: indented
17+
EnforcedStyle: aligned
1818

1919
Lint/MissingSuper:
2020
Enabled: false

app/apps/plugins/front_cache/front_cache_helper.rb

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ def front_cache_front_after_load
4545
cache_key = front_cache_plugin_cache_key
4646
return unless @_plugin_do_cache && !flash.keys.present?
4747

48-
args = { data: response.body
49-
.gsub(/csrf-token" content="(.*?)"/, 'csrf-token" content="{{form_authenticity_token}}"')
50-
.gsub(/name="authenticity_token" value="(.*?)"/, 'name="authenticity_token" value="{{form_authenticity_token}}"') }
48+
body =
49+
response
50+
.body.gsub(/csrf-token" content="(.*?)"/, 'csrf-token" content="{{form_authenticity_token}}"')
51+
.gsub(
52+
/name="authenticity_token" value="(.*?)"/, 'name="authenticity_token" value="{{form_authenticity_token}}"'
53+
)
54+
args = { data: body }
5155
hooks_run('front_cache_writing_cache', args)
5256
front_cache_plugin_cache_create(cache_key, args[:data])
5357
Rails.logger.info "Camaleon CMS - cache saved as: #{front_cache_plugin_get_path(cache_key)}"
@@ -57,13 +61,18 @@ def front_cache_front_after_load
5761
def front_cache_on_active(_plugin)
5862
return if current_site.get_meta('front_cache_elements', nil).present?
5963

60-
current_site.set_meta('front_cache_elements', { paths: [],
61-
posts: [],
62-
post_types: [current_site.post_types.where(slug: 'page').first.id],
63-
skip_posts: [],
64-
home: true,
65-
cache_login: true,
66-
cache_counter: 0 })
64+
current_site.set_meta(
65+
'front_cache_elements',
66+
{
67+
paths: [],
68+
posts: [],
69+
post_types: [current_site.post_types.where(slug: 'page').first.id],
70+
skip_posts: [],
71+
home: true,
72+
cache_login: true,
73+
cache_counter: 0
74+
}
75+
)
6776
end
6877

6978
# on uninstall plugin

app/validators/camaleon_cms/post_uniq_validator.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ def validate(record)
77
ptype = record.post_type
88
return unless ptype.present? # only for posts that belongs to a post type model
99

10+
post_table = CamaleonCms::Post.table_name
1011
posts = ptype.site.posts
1112
.where(
12-
"(#{slug_array.map { |s| "#{CamaleonCms::Post.table_name}.slug LIKE '%-->#{s}<!--%'" }
13-
.join(' OR ')} ) OR #{CamaleonCms::Post.table_name}.slug = ?", record.slug
13+
"(#{slug_array.map { |s| "#{post_table}.slug LIKE '%-->#{s}<!--%'" }
14+
.join(' OR ')} ) OR #{post_table}.slug = ?", record.slug
1415
)
1516
.where.not(id: record.id)
1617
.where.not(status: %i[draft draft_child trash])

spec/features/frontend/custom_fields_translation_malicious_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
.add_post(title: 'RCE Payload Post', slug: 'rce-payload-post', content: 'malicious content')
1919

2020
@secure_post.add_field(
21-
{ 'name' => 'Secure Checkbox', 'slug' => field_slug },
22-
{ 'field_key' => 'checkbox', 'translate' => false }
21+
{ 'name' => 'Secure Checkbox', 'slug' => field_slug }, { 'field_key' => 'checkbox', 'translate' => false }
2322
)
2423
@secure_post.set_field_value(field_slug, 'checked')
2524
end

spec/features/frontend/custom_fields_translation_safe_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
slug: post_type_slug,
1717
description: 'Isolated post type for i18n rendering regression checks'
1818
)
19-
@secure_post = secure_post_type
20-
.add_post(title: 'RCE Safe Translation Post', slug: 'rce-safe-translation-post', content: 'safe content')
19+
@secure_post = secure_post_type.add_post(
20+
title: 'RCE Safe Translation Post', slug: 'rce-safe-translation-post', content: 'safe content'
21+
)
2122

2223
@secure_post.add_field(
23-
{ 'name' => 'Secure Checkbox', 'slug' => field_slug },
24-
{ 'field_key' => 'checkbox', 'translate' => false }
24+
{ 'name' => 'Secure Checkbox', 'slug' => field_slug }, { 'field_key' => 'checkbox', 'translate' => false }
2525
)
2626
@secure_post.set_field_value(field_slug, 'checked')
2727
end

spec/requests/frontend/custom_fields_translation_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
.add_post(title: 'RCE Request Post', slug: 'rce-request-post', content: 'request content')
2121

2222
@secure_post.add_field(
23-
{ 'name' => 'Secure Checkbox', 'slug' => field_slug },
24-
{ 'field_key' => 'checkbox', 'translate' => false }
23+
{ 'name' => 'Secure Checkbox', 'slug' => field_slug }, { 'field_key' => 'checkbox', 'translate' => false }
2524
)
2625
@secure_post.set_field_value(field_slug, 'checked')
2726
end

spec/support/webfont_icon_check.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ def webfont_icon_fetch_status(icon_class, filnam_distinct_part, filnam_extension
2121
JS
2222

2323
# First find is iterating through the array of font faces, 2nd - through the split chunks of found font face
24-
url_str = icon_font_faces.find { |str| str.include?(filnam_distinct_part) && str.include?(filnam_extension) }.split
24+
url_str = icon_font_faces.find { |str| str.include?(filnam_distinct_part) && str.include?(filnam_extension) }
25+
.split
2526
.find { |str| str.include?(filnam_distinct_part) && str.include?(filnam_extension) }
26-
.delete_prefix('url("')
27-
.chomp('")')
27+
.delete_prefix('url("').chomp('")')
2828

2929
page.execute_script(<<~JS)
3030
let xhr = new XMLHttpRequest();

0 commit comments

Comments
 (0)