otwcode/otwarchive

View on GitHub
app/controllers/skins_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

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

  def index
    is_work_skin = params[:skin_type] && params[:skin_type] == "WorkSkin"
    if current_user && current_user.is_a?(User)
      @preference = current_user.preference
    end
Severity: Minor
Found in app/controllers/skins_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 create has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    unless params[:skin_type].nil? || params[:skin_type] && %w(Skin WorkSkin).include?(params[:skin_type])
      flash[:error] = ts("What kind of skin did you want to create?")
      redirect_to :new and return
    end
Severity: Minor
Found in app/controllers/skins_controller.rb - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    authorize @skin if logged_in_as_admin?

    loaded = load_archive_parents
    if @skin.update(skin_params)
Severity: Minor
Found in app/controllers/skins_controller.rb - About 1 hr 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 load_archive_parents has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def load_archive_parents
    if params[:add_site_parents]
      params[:skin][:skin_parents_attributes] ||= ActionController::Parameters.new
      archive_parents = Skin.get_current_site_skin.get_all_parents
      skin_parent_titles = params[:skin][:skin_parents_attributes].values.map { |v| v[:parent_skin_title] }
Severity: Minor
Found in app/controllers/skins_controller.rb - About 1 hr 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 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    is_work_skin = params[:skin_type] && params[:skin_type] == "WorkSkin"
    if current_user && current_user.is_a?(User)
      @preference = current_user.preference
    end
Severity: Minor
Found in app/controllers/skins_controller.rb - About 1 hr to fix

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

      def create
        unless params[:skin_type].nil? || params[:skin_type] && %w(Skin WorkSkin).include?(params[:skin_type])
          flash[:error] = ts("What kind of skin did you want to create?")
          redirect_to :new and return
        end
    Severity: Minor
    Found in app/controllers/skins_controller.rb - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status