Noosfero/noosfero

View on GitHub
plugins/fb_app/controllers/public/fb_app_plugin_page_tab_controller.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method index has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    return unless load_page_tabs

    if params[:tabs_added]
      @page_tabs = FbAppPlugin::PageTab.create_from_tabs_added params[:tabs_added]

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 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    return unless load_page_tabs

    if params[:tabs_added]
      @page_tabs = FbAppPlugin::PageTab.create_from_tabs_added params[:tabs_added]

    Method load_page_tabs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def load_page_tabs
          @signed_requests = read_param params[:signed_request]
          if @signed_requests.present?
            @datas = []
            @page_ids = @signed_requests.map do |signed_request|
    Severity: Minor
    Found in plugins/fb_app/controllers/public/fb_app_plugin_page_tab_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 admin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def admin
        return redirect_to "/plugin/fb_app/myprofile_config" if params[:page_id].blank? && params[:signed_request].blank?
        return unless load_page_tabs
    
        if request.put? && @page_id.present?
    Severity: Minor
    Found in plugins/fb_app/controllers/public/fb_app_plugin_page_tab_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

    There are no issues that match your filters.

    Category
    Status