QutBioacoustics/baw-server

View on GitHub

Showing 257 of 257 total issues

Avoid too many return statements within this method.
Open

      return nil if hash[:description].starts_with?('max_analyze_duration')
Severity: Major
Found in lib/gems/baw-audio-tools/lib/baw_audio_tools/audio_ffmpeg.rb - About 30 mins to fix

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

        def create_project_name(project, extra_options = '', extension = '')
          if project.is_a?(Hash)
            id = project[:id]
            name = project[:name]
          else
    Severity: Minor
    Found in app/modules/namey_wamey.rb and 1 other location - About 30 mins to fix
    app/modules/namey_wamey.rb on lines 83..92

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

    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 create_user_name(user, extra_options = '', extension = '')
          if user.is_a?(Hash)
            user_id = user[:id]
            user_name = user[:name]
          else
    Severity: Minor
    Found in app/modules/namey_wamey.rb and 1 other location - About 30 mins to fix
    app/modules/namey_wamey.rb on lines 40..49

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

    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 index
        do_authorize_class
        get_project_if_exists
        do_authorize_instance(:show, @project) unless @project.nil?
    
    
    Severity: Minor
    Found in app/controllers/sites_controller.rb and 1 other location - About 30 mins to fix
    app/controllers/regions_controller.rb on lines 9..22

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

    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 index
        do_authorize_class
        get_project_if_exists
        do_authorize_instance(:show, @project) unless @project.nil?
    
    
    Severity: Minor
    Found in app/controllers/regions_controller.rb and 1 other location - About 30 mins to fix
    app/controllers/sites_controller.rb on lines 8..22

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

    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 4 locations. Consider refactoring.
    Open

            {
              join: AudioEvent,
              on: Tagging.arel_table[:audio_event_id].eq(AudioEvent.arel_table[:id]),
              available: true
            },
    Severity: Minor
    Found in app/models/tagging.rb and 3 other locations - About 25 mins to fix
    app/models/analysis_jobs_item.rb on lines 84..93
    app/models/permission.rb on lines 116..125
    app/models/region.rb on lines 86..95

    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 4 locations. Consider refactoring.
    Open

                {
                  join: SavedSearch,
                  on: AnalysisJob.arel_table[:saved_search_id].eq(SavedSearch.arel_table[:id]),
                  available: true
                },
    Severity: Minor
    Found in app/models/analysis_jobs_item.rb and 3 other locations - About 25 mins to fix
    app/models/permission.rb on lines 116..125
    app/models/region.rb on lines 86..95
    app/models/tagging.rb on lines 65..74

    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 4 locations. Consider refactoring.
    Open

            {
              join: Project,
              on: Permission.arel_table[:project_id].eq(Project.arel_table[:id]),
              available: true
            },
    Severity: Minor
    Found in app/models/permission.rb and 3 other locations - About 25 mins to fix
    app/models/analysis_jobs_item.rb on lines 84..93
    app/models/region.rb on lines 86..95
    app/models/tagging.rb on lines 65..74

    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 check_cached_spectrogram_paths(file_name, source_existing, target_possible, modify_parameters)
              target_existing_paths = @spectrogram_cache.existing_paths(modify_parameters)
              if target_existing_paths.blank?
                msg = "Could not create cached spectrogram for #{file_name} from " \
                      " #{source_existing} in #{target_possible} using #{modify_parameters}."
    Severity: Minor
    Found in lib/gems/baw-workers/lib/baw_workers/jobs/media/work_helper.rb and 1 other location - About 25 mins to fix
    lib/gems/baw-workers/lib/baw_workers/jobs/media/work_helper.rb on lines 209..216

    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 check_cached_audio_paths(file_name, source_existing, target_possible, modify_parameters)
              target_existing_paths = @audio_cache.existing_paths(modify_parameters)
              if target_existing_paths.blank?
                msg = "Could not create cached audio for #{file_name} from " \
                      " #{source_existing} in #{target_possible} using #{modify_parameters}."
    Severity: Minor
    Found in lib/gems/baw-workers/lib/baw_workers/jobs/media/work_helper.rb and 1 other location - About 25 mins to fix
    lib/gems/baw-workers/lib/baw_workers/jobs/media/work_helper.rb on lines 219..226

    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 4 locations. Consider refactoring.
    Open

            {
              join: Project,
              on: Region.arel_table[:project_id].eq(Project.arel_table[:id]),
              available: true
            },
    Severity: Minor
    Found in app/models/region.rb and 3 other locations - About 25 mins to fix
    app/models/analysis_jobs_item.rb on lines 84..93
    app/models/permission.rb on lines 116..125
    app/models/tagging.rb on lines 65..74

    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

    Method info_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.info_hash(identifier, rails_identifier)
        tzinfo_tz = TimeZoneHelper.tzinfo_class(identifier)
        rails_tz = TimeZoneHelper.ruby_tz_class(rails_identifier)
    
        return nil unless tzinfo_tz
    Severity: Minor
    Found in app/modules/time_zone_helper.rb - About 25 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 compose_range_string_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def compose_range_string_node(node, range_string)
          validate_node_or_attribute(node)
    
          range_regex = /(\[|\()(.*),(.*)(\)|\])/i
          matches = range_string.match(range_regex)
    Severity: Minor
    Found in app/modules/filter/subset.rb - About 25 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 taxonomic_enforced has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def taxonomic_enforced
        if type_of_tag == 'common_name' || type_of_tag == 'species_name'
          errors.add(:is_taxonomic, "must be true for #{type_of_tag}") unless is_taxonomic
        elsif is_taxonomic
          errors.add(:is_taxonomic, "must be false for #{type_of_tag}")
    Severity: Minor
    Found in app/models/tag.rb - About 25 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 alphabetical_paginator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def alphabetical_paginator(current_page = 'a', window_size = 1, index_size = 1)
        raise if window_size < 1
        raise if index_size < 1
    
        other = AlphabeticalPaginatorQuery::OTHER #"\u{1F30F}"
    Severity: Minor
    Found in app/helpers/alphabetical_paginator_helper.rb - About 25 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 format_resque_worker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def format_resque_worker(result, settings)
            is_resque_worker = resque_worker?
            result[:resque_worker] = {
              running: is_resque_worker,
              mode: baw_workers_mode(settings),
    Severity: Minor
    Found in lib/gems/baw-workers/lib/baw_workers/config.rb - About 25 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 project_access_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def project_access_request(sender_user, project_ids, reason)
        @sender_user = sender_user
        @access_reason = reason
    
        user_projects = {}
    Severity: Minor
    Found in app/mailers/project_mailer.rb - About 25 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 validate_channel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_channel(opts)
            provided = validate_msg_provided(opts)
            raise ArgumentError, "#{validate_msg_base} channel. #{provided}" unless opts.include? :channel
            unless opts[:channel].to_i >= 0
              raise ArgumentError, "channel #{validate_msg_eq_or_gt} 0: #{opts[:channel]}. #{provided}"
    Severity: Minor
    Found in lib/gems/baw-workers/lib/baw_workers/storage/common.rb - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def update
        do_load_resource
        get_project_if_exists
        do_authorize_instance
    
    
    Severity: Minor
    Found in app/controllers/harvests_controller.rb - About 25 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 get_sign_in_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_sign_in_params
          # available parameters
          email = params[:email].presence
          login = params[:login].presence
          password = params[:password].presence
    Severity: Minor
    Found in app/modules/api/api_auth.rb - About 25 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

    Severity
    Category
    Status
    Source
    Language