amahi/platform

View on GitHub
plugins/050-network/app/controllers/network_controller.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class NetworkController has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class NetworkController < ApplicationController
  KIND = Setting::NETWORK
  before_action :admin_required
  before_action :set_page_title
  IP_RANGE = 10
Severity: Minor
Found in plugins/050-network/app/controllers/network_controller.rb - About 2 hrs to fix

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

      def update_lease_time
        sleep 2 if development?
        @saved = params[:lease_time].present? && params[:lease_time].to_i > 0 ? Setting.set("lease_time", params[:lease_time], KIND) : false
        render :json => { :status => @saved ? :ok : :not_acceptable }
        system("hda-ctl-hup")
    Severity: Minor
    Found in plugins/050-network/app/controllers/network_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_gateway has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_gateway
        sleep 2 if development?
        @saved = params[:gateway].to_i > 0 && params[:gateway].to_i < 255 ? Setting.set("gateway", params[:gateway], KIND) : false
        if @saved
          @net = Setting.get 'net'
    Severity: Minor
    Found in plugins/050-network/app/controllers/network_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