platformos-check 0.4.8 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/README.md +28 -19
- data/config/default.yml +13 -1
- data/docs/checks/form_action.md +6 -0
- data/docs/checks/form_authenticity_token.md +22 -3
- data/docs/checks/include_in_render.md +62 -0
- data/docs/checks/translation_files_match.md +70 -0
- data/docs/checks/translation_key_exists.md +44 -0
- data/docs/platformos-check.jpg +0 -0
- data/lib/platformos_check/app.rb +13 -0
- data/lib/platformos_check/app_file.rb +10 -3
- data/lib/platformos_check/checks/convert_include_to_render.rb +41 -2
- data/lib/platformos_check/checks/form_action.rb +3 -1
- data/lib/platformos_check/checks/form_authenticity_token.rb +20 -0
- data/lib/platformos_check/checks/img_lazy_loading.rb +6 -2
- data/lib/platformos_check/checks/include_in_render.rb +45 -0
- data/lib/platformos_check/checks/invalid_args.rb +4 -1
- data/lib/platformos_check/checks/translation_files_match.rb +83 -0
- data/lib/platformos_check/checks/translation_key_exists.rb +48 -0
- data/lib/platformos_check/checks/undefined_object.rb +55 -26
- data/lib/platformos_check/checks/unreachable_code.rb +9 -9
- data/lib/platformos_check/checks/unused_assign.rb +33 -24
- data/lib/platformos_check/cli.rb +1 -1
- data/lib/platformos_check/ext/hash.rb +19 -0
- data/lib/platformos_check/graphql_file.rb +4 -0
- data/lib/platformos_check/language_server/constants.rb +18 -2
- data/lib/platformos_check/language_server/document_link_provider.rb +67 -10
- data/lib/platformos_check/language_server/document_link_providers/localize_document_link_provider.rb +38 -0
- data/lib/platformos_check/language_server/document_link_providers/theme_render_document_link_provider.rb +2 -1
- data/lib/platformos_check/language_server/document_link_providers/translation_document_link_provider.rb +36 -0
- data/lib/platformos_check/tags/graphql.rb +3 -0
- data/lib/platformos_check/translation_file.rb +40 -0
- data/lib/platformos_check/version.rb +1 -1
- data/lib/platformos_check/yaml_file.rb +7 -2
- data/lib/platformos_check.rb +1 -0
- metadata +13 -4
- data/docs/preview.png +0 -0
@@ -8,7 +8,8 @@ module PlatformosCheck
|
|
8
8
|
@default_dir = 'views/partials'
|
9
9
|
@default_extension = '.liquid'
|
10
10
|
|
11
|
-
def file_link(
|
11
|
+
def file_link(match, platformos_app)
|
12
|
+
partial = match[:partial]
|
12
13
|
relative_path = nil
|
13
14
|
path_prefixes(platformos_app).each do |prefix|
|
14
15
|
prefix ||= ''
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformosCheck
|
4
|
+
module LanguageServer
|
5
|
+
class TranslationDocumentLinkProvider < DocumentLinkProvider
|
6
|
+
@partial_regexp = TRANSLATION_FILTER
|
7
|
+
@app_file_type = :translations
|
8
|
+
@default_dir = 'translations'
|
9
|
+
@default_extension = '.yml'
|
10
|
+
|
11
|
+
def file_link(match, platformos_app)
|
12
|
+
translation_file_link(match, platformos_app)
|
13
|
+
end
|
14
|
+
|
15
|
+
def translation_components_for_match(match)
|
16
|
+
translation_components = match[:key].split('.')
|
17
|
+
translation_components = match[:scope].split('.') + translation_components if match[:scope]
|
18
|
+
[translation_components]
|
19
|
+
end
|
20
|
+
|
21
|
+
def start_coordinates(buffer, match)
|
22
|
+
from_index_to_row_column(
|
23
|
+
buffer,
|
24
|
+
match.begin(:key)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def end_coordinates(buffer, match)
|
29
|
+
from_index_to_row_column(
|
30
|
+
buffer,
|
31
|
+
match.end(:key)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -5,6 +5,7 @@ module PlatformosCheck
|
|
5
5
|
class Graphql < Base
|
6
6
|
QUERY_NAME_SYNTAX = /(#{Liquid::VariableSignature}+)\s*=\s*(.*)\s*/om
|
7
7
|
INLINE_SYNTAX = /(#{Liquid::QuotedFragment}+)(\s*(#{Liquid::QuotedFragment}+))?/o
|
8
|
+
INLINE_SYNTAX_WITHOUT_RESULT_VARIABLE = /\A([\w\-\.\[\]])+\s*:\s*/om
|
8
9
|
CLOSE_TAG_SYNTAX = /\A(.*)(?-mix:\{%-?)\s*(\w+)\s*(.*)?(?-mix:%\})\z/m # based on Liquid::Raw::FullTokenPossiblyInvalid
|
9
10
|
|
10
11
|
attr_reader :to, :from, :inline_query, :value_expr, :partial_name, :attributes_expr, :attributes
|
@@ -28,6 +29,8 @@ module PlatformosCheck
|
|
28
29
|
@partial_name = value_expr
|
29
30
|
@from = Liquid::Variable.new(after_assign_markup.join('|'), options)
|
30
31
|
elsif INLINE_SYNTAX.match?(markup)
|
32
|
+
raise Liquid::SyntaxError, 'Invalid syntax for inline graphql tag - missing result name. Valid syntax: graphql result, arg1: var1, ...' if markup.match?(INLINE_SYNTAX_WITHOUT_RESULT_VARIABLE)
|
33
|
+
|
31
34
|
@inline_query = true
|
32
35
|
parse_markup(tag_name, markup)
|
33
36
|
@attributes = attributes_expr.keys
|
@@ -2,5 +2,45 @@
|
|
2
2
|
|
3
3
|
module PlatformosCheck
|
4
4
|
class TranslationFile < YamlFile
|
5
|
+
DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(translations)/|modules/((\w|-)*)/(private|public)/(translations)/)}
|
6
|
+
TRANSLATION_FILTERS = Set.new(%w[t t_escape translate translate_escape]).freeze
|
7
|
+
attr_reader :language
|
8
|
+
|
9
|
+
def load!
|
10
|
+
before_load
|
11
|
+
super
|
12
|
+
after_load
|
13
|
+
end
|
14
|
+
|
15
|
+
def before_load
|
16
|
+
@storage.platformos_app.instance_variable_set(:@translations_hash, nil) unless @loaded
|
17
|
+
end
|
18
|
+
|
19
|
+
def after_load
|
20
|
+
@language = @content&.keys&.first
|
21
|
+
return if module_name.nil?
|
22
|
+
|
23
|
+
@content[@language].transform_keys! { |key| key.start_with?(module_prefix) ? key : "#{module_prefix}#{key}" }
|
24
|
+
end
|
25
|
+
|
26
|
+
def language_from_path
|
27
|
+
@language_from_path ||= name.sub(module_prefix, '').split(File::SEPARATOR).first
|
28
|
+
end
|
29
|
+
|
30
|
+
def update_contents(new_content = {})
|
31
|
+
before_load
|
32
|
+
super(new_content)
|
33
|
+
@loaded = true
|
34
|
+
|
35
|
+
after_load
|
36
|
+
end
|
37
|
+
|
38
|
+
def dir_prefix
|
39
|
+
DIR_PREFIX
|
40
|
+
end
|
41
|
+
|
42
|
+
def translation?
|
43
|
+
true
|
44
|
+
end
|
5
45
|
end
|
6
46
|
end
|
@@ -28,14 +28,19 @@ module PlatformosCheck
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def write
|
31
|
+
pretty = content_to_string
|
32
|
+
@storage.write(@relative_path, pretty)
|
33
|
+
@source = pretty
|
34
|
+
end
|
35
|
+
|
36
|
+
def content_to_string
|
31
37
|
pretty = YAML.dump(@content)
|
32
38
|
return unless source.rstrip != pretty.rstrip
|
33
39
|
|
34
40
|
# Most editors add a trailing \n at the end of files. Here we
|
35
41
|
# try to maintain the convention.
|
36
42
|
eof = source.end_with?("\n") ? "\n" : ""
|
37
|
-
|
38
|
-
@source = pretty
|
43
|
+
pretty.gsub("\n", @eol) + eof
|
39
44
|
end
|
40
45
|
|
41
46
|
def yaml?
|
data/lib/platformos_check.rb
CHANGED
@@ -5,6 +5,7 @@ require "liquid"
|
|
5
5
|
require_relative "platformos_check/version"
|
6
6
|
require_relative "platformos_check/bug"
|
7
7
|
require_relative "platformos_check/exceptions"
|
8
|
+
require_relative "platformos_check/ext/hash"
|
8
9
|
require_relative "platformos_check/json_helper"
|
9
10
|
require_relative "platformos_check/app_file_rewriter"
|
10
11
|
require_relative "platformos_check/app_file"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: platformos-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Bliszczyk
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: graphql
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- docs/checks/html_parsing_error.md
|
124
124
|
- docs/checks/img_lazy_loading.md
|
125
125
|
- docs/checks/img_width_and_height.md
|
126
|
+
- docs/checks/include_in_render.md
|
126
127
|
- docs/checks/invalid_args.md
|
127
128
|
- docs/checks/liquid_tag.md
|
128
129
|
- docs/checks/missing_enable_comment.md
|
@@ -133,6 +134,8 @@ files:
|
|
133
134
|
- docs/checks/space_inside_braces.md
|
134
135
|
- docs/checks/syntax_error.md
|
135
136
|
- docs/checks/template_length.md
|
137
|
+
- docs/checks/translation_files_match.md
|
138
|
+
- docs/checks/translation_key_exists.md
|
136
139
|
- docs/checks/undefined_object.md
|
137
140
|
- docs/checks/unknown_filter.md
|
138
141
|
- docs/checks/unreachable_code.md
|
@@ -147,7 +150,7 @@ files:
|
|
147
150
|
- docs/language_server/code-action-problem.png
|
148
151
|
- docs/language_server/code-action-quickfix.png
|
149
152
|
- docs/language_server/how_to_correct_code_with_code_actions_and_execute_command.md
|
150
|
-
- docs/
|
153
|
+
- docs/platformos-check.jpg
|
151
154
|
- exe/platformos-check
|
152
155
|
- exe/platformos-check-language-server
|
153
156
|
- lib/platformos_check.rb
|
@@ -169,6 +172,7 @@ files:
|
|
169
172
|
- lib/platformos_check/checks/html_parsing_error.rb
|
170
173
|
- lib/platformos_check/checks/img_lazy_loading.rb
|
171
174
|
- lib/platformos_check/checks/img_width_and_height.rb
|
175
|
+
- lib/platformos_check/checks/include_in_render.rb
|
172
176
|
- lib/platformos_check/checks/invalid_args.rb
|
173
177
|
- lib/platformos_check/checks/liquid_tag.rb
|
174
178
|
- lib/platformos_check/checks/missing_enable_comment.rb
|
@@ -179,6 +183,8 @@ files:
|
|
179
183
|
- lib/platformos_check/checks/space_inside_braces.rb
|
180
184
|
- lib/platformos_check/checks/syntax_error.rb
|
181
185
|
- lib/platformos_check/checks/template_length.rb
|
186
|
+
- lib/platformos_check/checks/translation_files_match.rb
|
187
|
+
- lib/platformos_check/checks/translation_key_exists.rb
|
182
188
|
- lib/platformos_check/checks/undefined_object.rb
|
183
189
|
- lib/platformos_check/checks/unknown_filter.rb
|
184
190
|
- lib/platformos_check/checks/unreachable_code.rb
|
@@ -194,6 +200,7 @@ files:
|
|
194
200
|
- lib/platformos_check/disabled_checks.rb
|
195
201
|
- lib/platformos_check/email_file.rb
|
196
202
|
- lib/platformos_check/exceptions.rb
|
203
|
+
- lib/platformos_check/ext/hash.rb
|
197
204
|
- lib/platformos_check/file_system_storage.rb
|
198
205
|
- lib/platformos_check/form_file.rb
|
199
206
|
- lib/platformos_check/graphql_file.rb
|
@@ -242,8 +249,10 @@ files:
|
|
242
249
|
- lib/platformos_check/language_server/document_link_providers/graphql_document_link_provider.rb
|
243
250
|
- lib/platformos_check/language_server/document_link_providers/include_document_link_provider.rb
|
244
251
|
- lib/platformos_check/language_server/document_link_providers/include_form_document_link_provider.rb
|
252
|
+
- lib/platformos_check/language_server/document_link_providers/localize_document_link_provider.rb
|
245
253
|
- lib/platformos_check/language_server/document_link_providers/render_document_link_provider.rb
|
246
254
|
- lib/platformos_check/language_server/document_link_providers/theme_render_document_link_provider.rb
|
255
|
+
- lib/platformos_check/language_server/document_link_providers/translation_document_link_provider.rb
|
247
256
|
- lib/platformos_check/language_server/execute_command_engine.rb
|
248
257
|
- lib/platformos_check/language_server/execute_command_provider.rb
|
249
258
|
- lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb
|
@@ -364,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
364
373
|
- !ruby/object:Gem::Version
|
365
374
|
version: '0'
|
366
375
|
requirements: []
|
367
|
-
rubygems_version: 3.
|
376
|
+
rubygems_version: 3.5.6
|
368
377
|
signing_key:
|
369
378
|
specification_version: 4
|
370
379
|
summary: A platformOS App Linter
|
data/docs/preview.png
DELETED
Binary file
|