SpeciesFileGroup/taxonworks

View on GitHub
lib/vendor/sqed_to_taxonworks.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Class Result has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Result
    SMALL_WIDTH = 100
    LARGE_WIDTH = 400

    TEXT_MAP = {
Severity: Minor
Found in lib/vendor/sqed_to_taxonworks.rb - About 3 hrs to fix

    Method process_result has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_result(use_thumbnail: true)
          begin
            sqed.use_thumbnail = use_thumbnail
            r = sqed.result
          rescue Sqed::Error
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method depiction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def depiction
          if @depiction
            @depiction
          else
            begin
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Avoid using update_column because it skips validations.
    Open

            sqed_depiction.update_column(:result_boundary_coordinates, nil)
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb by rubocop

    This cop checks for the use of methods which skip validations which are listed in https://guides.rubyonrails.org/active_record_validations.html#skipping-validations

    Methods may be ignored from this rule by configuring a Whitelist.

    Example:

    # bad
    Article.first.decrement!(:view_count)
    DiscussionBoard.decrement_counter(:post_count, 5)
    Article.first.increment!(:view_count)
    DiscussionBoard.increment_counter(:post_count, 5)
    person.toggle :active
    product.touch
    Billing.update_all("category = 'authorized', author = 'David'")
    user.update_attribute(:website, 'example.com')
    user.update_columns(last_request_at: Time.current)
    Post.update_counters 5, comment_count: -1, action_count: 1
    
    # good
    user.update(website: 'example.com')
    FileUtils.touch('file')

    Example: Whitelist: ["touch"]

    # bad
    DiscussionBoard.decrement_counter(:post_count, 5)
    DiscussionBoard.increment_counter(:post_count, 5)
    person.toggle :active
    
    # good
    user.touch

    Avoid using touch because it skips validations.
    Open

          sqed_depiction.touch
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb by rubocop

    This cop checks for the use of methods which skip validations which are listed in https://guides.rubyonrails.org/active_record_validations.html#skipping-validations

    Methods may be ignored from this rule by configuring a Whitelist.

    Example:

    # bad
    Article.first.decrement!(:view_count)
    DiscussionBoard.decrement_counter(:post_count, 5)
    Article.first.increment!(:view_count)
    DiscussionBoard.increment_counter(:post_count, 5)
    person.toggle :active
    product.touch
    Billing.update_all("category = 'authorized', author = 'David'")
    user.update_attribute(:website, 'example.com')
    user.update_columns(last_request_at: Time.current)
    Post.update_counters 5, comment_count: -1, action_count: 1
    
    # good
    user.update(website: 'example.com')
    FileUtils.touch('file')

    Example: Whitelist: ["touch"]

    # bad
    DiscussionBoard.decrement_counter(:post_count, 5)
    DiscussionBoard.increment_counter(:post_count, 5)
    person.toggle :active
    
    # good
    user.touch

    Avoid using update_column because it skips validations.
    Open

          sqed_depiction.update_column(:result_ocr, (sqed_result || nil)&.text)
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb by rubocop

    This cop checks for the use of methods which skip validations which are listed in https://guides.rubyonrails.org/active_record_validations.html#skipping-validations

    Methods may be ignored from this rule by configuring a Whitelist.

    Example:

    # bad
    Article.first.decrement!(:view_count)
    DiscussionBoard.decrement_counter(:post_count, 5)
    Article.first.increment!(:view_count)
    DiscussionBoard.increment_counter(:post_count, 5)
    person.toggle :active
    product.touch
    Billing.update_all("category = 'authorized', author = 'David'")
    user.update_attribute(:website, 'example.com')
    user.update_columns(last_request_at: Time.current)
    Post.update_counters 5, comment_count: -1, action_count: 1
    
    # good
    user.update(website: 'example.com')
    FileUtils.touch('file')

    Example: Whitelist: ["touch"]

    # bad
    DiscussionBoard.decrement_counter(:post_count, 5)
    DiscussionBoard.increment_counter(:post_count, 5)
    person.toggle :active
    
    # good
    user.touch

    Avoid using update_column because it skips validations.
    Open

            sqed_depiction.update_column(:result_boundary_coordinates, sqed.boundaries.coordinates)
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb by rubocop

    This cop checks for the use of methods which skip validations which are listed in https://guides.rubyonrails.org/active_record_validations.html#skipping-validations

    Methods may be ignored from this rule by configuring a Whitelist.

    Example:

    # bad
    Article.first.decrement!(:view_count)
    DiscussionBoard.decrement_counter(:post_count, 5)
    Article.first.increment!(:view_count)
    DiscussionBoard.increment_counter(:post_count, 5)
    person.toggle :active
    product.touch
    Billing.update_all("category = 'authorized', author = 'David'")
    user.update_attribute(:website, 'example.com')
    user.update_columns(last_request_at: Time.current)
    Post.update_counters 5, comment_count: -1, action_count: 1
    
    # good
    user.update(website: 'example.com')
    FileUtils.touch('file')

    Example: Whitelist: ["touch"]

    # bad
    DiscussionBoard.decrement_counter(:post_count, 5)
    DiscussionBoard.increment_counter(:post_count, 5)
    person.toggle :active
    
    # good
    user.touch

    TODO found
    Open

          # TODO: likely remove TypeError
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb by fixme

    TODO found
    Open

        # TODO: should be set_cached
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb by fixme

    TODO found
    Open

            sqed_depiction.result_boundary_coordinates[index.to_s].to_a # TODO- hmm, why the to_s needed here
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb by fixme

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

        def image_path_for_small_image(layout_section_type)
          c = coords_for(layout_section_type)
          "/images/#{depiction.image.id}/scale_to_box/#{c[0]}/#{c[1]}/#{c[2]}/#{c[3]}/150/150"
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb and 1 other location - About 25 mins to fix
    lib/vendor/sqed_to_taxonworks.rb on lines 181..183

    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 31.

    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 image_path_for_large_image(layout_section_type)
          c = coords_for(layout_section_type)
          "/images/#{depiction.image.id}/scale_to_box/#{c[0]}/#{c[1]}/#{c[2]}/#{c[3]}/400/400"
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb and 1 other location - About 25 mins to fix
    lib/vendor/sqed_to_taxonworks.rb on lines 186..188

    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 31.

    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 image_path_for(layout_section_type)
          c = coords_for(layout_section_type)
          "/images/#{depiction.image.id}/extract/#{c[0]}/#{c[1]}/#{c[2]}/#{c[3]}"
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb and 1 other location - About 25 mins to fix
    lib/vendor/sqed_to_taxonworks.rb on lines 191..193

    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 30.

    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 ocr_path_for(layout_section_type)
          c = coords_for(layout_section_type)
          "/images/#{depiction.image.id}/ocr/#{c[0]}/#{c[1]}/#{c[2]}/#{c[3]}"
    Severity: Minor
    Found in lib/vendor/sqed_to_taxonworks.rb and 1 other location - About 25 mins to fix
    lib/vendor/sqed_to_taxonworks.rb on lines 176..178

    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 30.

    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

    There are no issues that match your filters.

    Category
    Status