phateio/kiris

View on GitHub
app/controllers/upload/niconico_controller.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method fetch has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def fetch
    set_site_title(I18n.t('upload.niconico.title'))
    @track = Track.new(track_params)
    if @track.niconico.empty?
      flash.now[:error] = I18n.t('upload.niconico.blank_niconico_id')
Severity: Minor
Found in app/controllers/upload/niconico_controller.rb - About 2 hrs 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 fetch has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def fetch
    set_site_title(I18n.t('upload.niconico.title'))
    @track = Track.new(track_params)
    if @track.niconico.empty?
      flash.now[:error] = I18n.t('upload.niconico.blank_niconico_id')
Severity: Major
Found in app/controllers/upload/niconico_controller.rb - About 2 hrs 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

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

          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

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

            def get_niconico_thumb_info(video_id)
              res_body = http_get_response_body("http://ext.nicovideo.jp/api/getthumbinfo/#{video_id}") rescue nil
              return false if res_body.nil?
              thumb_info_doc = Nokogiri::XML(res_body)
              thumb_element = thumb_info_doc.xpath('/nicovideo_thumb_response/thumb')
          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

          There are no issues that match your filters.

          Category
          Status