Skip to content
Snippets Groups Projects
Commit ea37199b authored by Doug Stull's avatar Doug Stull :two:
Browse files

Merge branch 'pl-cop-static-translation-definition-multiline' into 'master'

Cop/StaticTranslationDefinition: Check multiline strings

See merge request !98205



Merged-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Approved-by: Adam Hegyi's avatarAdam Hegyi <ahegyi@gitlab.com>
Approved-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
Co-authored-by: Peter Leitzen's avatarPeter Leitzen <pleitzen@gitlab.com>
parents a64bc616 5b98aa47
No related branches found
No related tags found
1 merge request!98205Cop/StaticTranslationDefinition: Check multiline strings
Pipeline #644354948 passed with warnings
Pipeline: GitLab

#644373775

    Pipeline: GitLab

    #644373756

      ......@@ -64,7 +64,7 @@ class StaticTranslationDefinition < RuboCop::Cop::Base
      NON_METHOD_DEFINITIONS = %i[class_methods included prepended].to_set.freeze
      def_node_matcher :translation_method?, <<~PATTERN
      (send _ {#{RESTRICT_ON_SEND.map(&:inspect).join(' ')}} str*)
      (send _ {#{RESTRICT_ON_SEND.map(&:inspect).join(' ')}} {dstr str}+)
      PATTERN
      def on_send(node)
      ......
      ......@@ -38,6 +38,15 @@
      C = n_("c")
      ^^^^^^^ #{msg}
      CODE
      <<~'CODE',
      A = _('a' \
      ^^^^^^^ [...]
      'b')
      CODE
      <<~'CODE',
      A = _("a#{s}")
      ^^^^^^^^^^ [...]
      CODE
      <<~CODE,
      class MyClass
      def self.translations
      ......@@ -100,6 +109,9 @@ class MyClass
      'CONSTANT_1 = __("a")',
      'CONSTANT_2 = s__("a")',
      'CONSTANT_3 = n__("a")',
      'CONSTANT_var = _(code)',
      'CONSTANT_int = _(1)',
      'CONSTANT_none = _()',
      <<~CODE,
      class MyClass
      def self.method
      ......
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Finish editing this message first!
      Please register or to comment