phateio/kiris

View on GitHub

Showing 43 of 43 total issues

Method update has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update
    id = params[:id]

    issue_id = request.POST[:issue_id].to_i
    issue_status = request.POST[:issue_status].to_s
Severity: Minor
Found in app/controllers/issues_controller.rb - About 1 hr to fix

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

      def new_issue_notify(subject, message, nickname)
        @message = message
        default_from = Rails.application.config.action_mailer.default_options.to_h[:from]
        mailer_from = default_from ? "#{nickname} <#{default_from}>" : "#{nickname}"
        mailer_to = 'JRS <admin@phate.io>'
    Severity: Minor
    Found in app/mailers/system_mailer.rb and 1 other location - About 45 mins to fix
    app/mailers/system_mailer.rb on lines 10..16

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

    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 new_issue_reply_notify(subject, message, nickname)
        @message = message
        default_from = Rails.application.config.action_mailer.default_options.to_h[:from]
        mailer_from = default_from ? "#{nickname} <#{default_from}>" : "#{nickname}"
        mailer_to = 'JRS <admin@phate.io>'
    Severity: Minor
    Found in app/mailers/system_mailer.rb and 1 other location - About 45 mins to fix
    app/mailers/system_mailer.rb on lines 2..8

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

    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 confirm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def confirm
        @track = Track.find(track_id)
        set_site_title(I18n.t('admin.track.review_title_with_index', id: @track.id))
        message = ''
        message += "Title: 「#{@track.title}」→「#{track_params[:title]}」" if @track.title != track_params[:title]
    Severity: Minor
    Found in app/controllers/admin/tracks_controller.rb - About 45 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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        items = []
        playlist_colle = Playlist.includes(:track).order(playedtime: :desc, id: :asc).limit(4).load
        playlist_colle.each do |playlist|
          track = playlist.track
    Severity: Minor
    Found in app/controllers/bridge/playlist_controller.rb - About 45 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 redirect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def redirect
        icy_metadata = request.env['HTTP_ICY_METADATA']
        request_protocol = request.protocol # Returns 'https://' if this is an SSL request and 'http://' otherwise.
    
        if $ICECAST_SERVER
    Severity: Minor
    Found in app/controllers/listen_controller.rb - About 45 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

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

      def show
        set_site_title("#{I18n.t('navbar.images')}##{track_id}")
        @image = Image.new
        @image.track = Track.find(track_id)
        @images = Image.includes(:track).where(track_id: track_id).order(id: :desc).page(page).per(20).load
    Severity: Minor
    Found in app/controllers/images_controller.rb and 1 other location - About 35 mins to fix
    app/controllers/tracks/images_controller.rb on lines 7..11

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

    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
        set_site_title("#{I18n.t('navbar.images')}##{track_id}")
        @image = Image.new
        @image.track = Track.find(track_id)
        @images = Image.includes(:track).where(track_id: track_id).order(id: :desc).page(page).per(20).load
    Severity: Minor
    Found in app/controllers/tracks/images_controller.rb and 1 other location - About 35 mins to fix
    app/controllers/images_controller.rb on lines 10..14

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

    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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        set_site_title("#{I18n.t('navbar.images')}##{track_id}")
        userip = @client[:ip]
        @track = Track.find(track_id)
        @image = @track.images.build(image_params)
    Severity: Minor
    Found in app/controllers/tracks/images_controller.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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def destroy
        id = params[:id]
    
        issue_id = request.POST[:issue_id].to_i
        reply_id = request.POST[:reply_id].to_i
    Severity: Minor
    Found in app/controllers/issues_controller.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

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

          @items << {id: issue.id,
                     dateline: issue.dateline,
                     subject: issue.subject,
                     message: issue.message,
                     nickname: nickname,
    Severity: Minor
    Found in app/controllers/issues_controller.rb and 1 other location - About 30 mins to fix
    app/controllers/issues_controller.rb on lines 107..117

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

    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

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

          @item = {id: issue.id,
                   dateline: issue.dateline,
                   subject: issue.subject,
                   message: issue.message,
                   nickname: nickname,
    Severity: Minor
    Found in app/controllers/issues_controller.rb and 1 other location - About 30 mins to fix
    app/controllers/issues_controller.rb on lines 30..40

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

    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

    Avoid too many return statements within this method.
    Open

            return 'Hong Kong'
    Severity: Major
    Found in app/controllers/application_controller.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return 'Taipei'
      Severity: Major
      Found in app/controllers/application_controller.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              render 'new' and return
        Severity: Major
        Found in app/controllers/upload/niconico_controller.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                render 'new' and return
          Severity: Major
          Found in app/controllers/upload/niconico_controller.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return 'Beijing'
            Severity: Major
            Found in app/controllers/application_controller.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    render 'new' and return
              Severity: Major
              Found in app/controllers/upload/niconico_controller.rb - About 30 mins to fix

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

                  def set_locale!
                    I18n.locale = I18n.default_locale
                    @@available_locales ||= I18n.available_locales.map(&:to_s)
                    if preference_params['locale']
                      locale = preference_params['locale']
                Severity: Minor
                Found in app/controllers/application_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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def update
                    set_site_title(I18n.t('upload.niconico.title'))
                    @track = Track.find(track_id)
                    redirect_to_index_if_not_permitted(@track); return if performed?
                    @track.attributes = track_params
                Severity: Minor
                Found in app/controllers/upload/niconico_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

                Severity
                Category
                Status
                Source
                Language