SpeciesFileGroup/taxonworks

View on GitHub
app/helpers/workbench/navigation_helper.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Tagging a string as html safe may be a security risk.
Open

        slideout_clipboard ].join.html_safe

This cop checks for the use of output safety calls like html_safe, raw, and safe_concat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

Example:

user_content = "hi"

# bad
"

#{user_content}

".html_safe # => ActiveSupport::SafeBuffer "

hi

" # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

<b>hi</b>

" # bad out = "" out << "
  • #{user_content}
  • " out << "
  • #{user_content}
  • " out.html_safe # => ActiveSupport::SafeBuffer "
  • hi
  • hi
  • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
  • <b>hi</b>
  • <b>hi</b>
  • " # bad out = "

    trusted content

    ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

    trusted_content

    hi" # good out = "

    trusted content

    ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

    trusted_content

    <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

    Tagging a string as html safe may be a security risk.
    Open

            letters.collect{|l| content_tag(:li, link_to("#{l}", "\##{l}")) }.join.html_safe

    This cop checks for the use of output safety calls like html_safe, raw, and safe_concat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

    Example:

    user_content = "hi"
    
    # bad
    "

    #{user_content}

    ".html_safe # => ActiveSupport::SafeBuffer "

    hi

    " # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

    <b>hi</b>

    " # bad out = "" out << "
  • #{user_content}
  • " out << "
  • #{user_content}
  • " out.html_safe # => ActiveSupport::SafeBuffer "
  • hi
  • hi
  • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
  • <b>hi</b>
  • <b>hi</b>
  • " # bad out = "

    trusted content

    ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

    trusted_content

    hi" # good out = "

    trusted content

    ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

    trusted_content

    <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

    Tagging a string as html safe may be a security risk.
    Open

          link_to(t.html_safe, metamorphosize_if(object))

    This cop checks for the use of output safety calls like html_safe, raw, and safe_concat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

    Example:

    user_content = "hi"
    
    # bad
    "

    #{user_content}

    ".html_safe # => ActiveSupport::SafeBuffer "

    hi

    " # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

    <b>hi</b>

    " # bad out = "" out << "
  • #{user_content}
  • " out << "
  • #{user_content}
  • " out.html_safe # => ActiveSupport::SafeBuffer "
  • hi
  • hi
  • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
  • <b>hi</b>
  • <b>hi</b>
  • " # bad out = "

    trusted content

    ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

    trusted_content

    hi" # good out = "

    trusted content

    ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

    trusted_content

    <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

    Tagging a string as html safe may be a security risk.
    Open

        content_tag(:span, (previous_link(instance) + ' | ' + next_link(instance)).html_safe)

    This cop checks for the use of output safety calls like html_safe, raw, and safe_concat. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use safe_join to join content and escape it and concat to concatenate content and escape it, ensuring its safety.

    Example:

    user_content = "hi"
    
    # bad
    "

    #{user_content}

    ".html_safe # => ActiveSupport::SafeBuffer "

    hi

    " # good content_tag(:p, user_content) # => ActiveSupport::SafeBuffer "

    <b>hi</b>

    " # bad out = "" out << "
  • #{user_content}
  • " out << "
  • #{user_content}
  • " out.html_safe # => ActiveSupport::SafeBuffer "
  • hi
  • hi
  • " # good out = [] out << content_tag(:li, user_content) out << content_tag(:li, user_content) safe_join(out) # => ActiveSupport::SafeBuffer # "
  • <b>hi</b>
  • <b>hi</b>
  • " # bad out = "

    trusted content

    ".html_safe out.safe_concat(user_content) # => ActiveSupport::SafeBuffer "

    trusted_content

    hi" # good out = "

    trusted content

    ".html_safe out.concat(user_content) # => ActiveSupport::SafeBuffer # "

    trusted_content

    <b>hi</b>" # safe, though maybe not good style out = "trusted content" result = out.concat(user_content) # => String "trusted contenthi" # because when rendered in ERB the String will be escaped: # <%= result %> # => trusted content<b>hi</b> # bad (user_content + " " + content_tag(:span, user_content)).html_safe # => ActiveSupport::SafeBuffer "hi <span><b>hi</b></span>" # good safe_join([user_content, " ", content_tag(:span, user_content)]) # => ActiveSupport::SafeBuffer # "<b>hi</b> <span>&lt;b&gt;hi&lt;/b&gt;</span>"

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      def next_link(instance, text: 'Next', target: nil)
        link_text = content_tag(:span, text, 'class' => 'small-icon icon-right', 'data-icon' => 'arrow-right')
        link_object = instance.next
        return content_tag(:div, link_text, 'class' => 'navigation-item disable') if link_object.nil?
        if target.nil?
    Severity: Major
    Found in app/helpers/workbench/navigation_helper.rb and 1 other location - About 1 hr to fix
    app/helpers/workbench/navigation_helper.rb on lines 82..91

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 51.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      def previous_link(instance, text: 'Previous', target: nil)
        link_text = content_tag(:span, text,  'data-icon' => 'arrow-left', 'class' => 'small-icon')
        link_object = instance.previous
        return content_tag(:div, link_text, 'class' => 'navigation-item disable') if link_object.nil?
        if target.nil?
    Severity: Major
    Found in app/helpers/workbench/navigation_helper.rb and 1 other location - About 1 hr to fix
    app/helpers/workbench/navigation_helper.rb on lines 96..105

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 51.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Prefer symbols instead of strings as hash keys.
    Open

        link_text = content_tag(:span, text,  'data-icon' => 'arrow-left', 'class' => 'small-icon')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        link_text = content_tag(:span, text,  'data-icon' => 'arrow-left', 'class' => 'small-icon')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        return content_tag(:div, link_text, 'class' => 'navigation-item disable') if link_object.nil?

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        link_to(link_text, target, 'data-arrow' => 'back', 'class' => 'navigation-item')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          link_to('New', new_source_path, 'class' => 'small-icon', 'data-icon' => 'new')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          content_tag(:div, content_tag(:span, 'Edit', 'data-icon' => 'edit', class: 'small-icon'), class: 'navigation-item disable')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        link_to(link_text, target, 'data-arrow' => 'next', 'class' => 'navigation-item')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        link_text = content_tag(:span, text, 'class' => 'small-icon icon-right', 'data-icon' => 'arrow-right')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          link_to('List', list_path_for_model(model), 'data-icon' => 'list')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          link_to('Batch load', {action: :batch_load, controller: self.controller_name}, 'data-icon' => 'batch')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          content_tag(:span, 'Batch load', class: 'disabled', 'data-icon' => 'batch')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        return content_tag(:div, link_text, 'class' => 'navigation-item disable') if link_object.nil?

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          link_to(content_tag(:span, 'New', 'class' => 'small-icon', data: { icon: :new }), new_path_for_model(model), 'class' => 'navigation-item')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          content_tag(:span, 'List', class: :disabled, 'data-icon' => 'list')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          link_to(content_tag(:span, 'Destroy', 'data-icon' => 'trash', class: 'small-icon'), object.metamorphosize, method: :delete, data: {confirm: 'Are you sure?'}, class: 'navigation-item')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        link_text = content_tag(:span, text, 'class' => 'small-icon icon-right', 'data-icon' => 'arrow-right')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          link_to('New', new_source_path, 'class' => 'small-icon', 'data-icon' => 'new')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          link_to(content_tag(:span, 'New', 'class' => 'small-icon', data: { icon: :new }), new_path_for_model(model), 'class' => 'navigation-item')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        link_to(link_text, target, 'data-arrow' => 'back', 'class' => 'navigation-item')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          link_to(content_tag(:span, 'Edit', 'data-icon' => 'edit', class: 'small-icon'), edit_object_path(metamorphosize_if(object)), class: 'navigation-item')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

          content_tag(:div, content_tag(:span, 'Destroy', 'data-icon' => 'trash', class: 'small-icon'), class: 'navigation-item disable')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    Prefer symbols instead of strings as hash keys.
    Open

        link_to(link_text, target, 'data-arrow' => 'next', 'class' => 'navigation-item')

    This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

    Example:

    # bad
    { 'one' => 1, 'two' => 2, 'three' => 3 }
    
    # good
    { one: 1, two: 2, three: 3 }

    There are no issues that match your filters.

    Category
    Status