gadzorg/gram2_api_server

View on GitHub

Showing 6 of 16 total issues

File accounts_controller.rb has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Api::V2::AccountsController < Api::V2::BaseController
  before_action :set_api_v2_account,
                only: %i[
                  show
                  edit
Severity: Minor
Found in app/controllers/api/v2/accounts_controller.rb - About 2 hrs to fix

    Method merge_changes_hash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def merge_changes_hash(_old_h,new_h)
        old_h=_old_h.dup
        new_h.each_pair do |k,v|
          old_value = old_h[k]
    
    

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

      def index
        filter =
          params.permit(
            :hruid,
            :id_soce,
    Severity: Minor
    Found in app/controllers/api/v2/accounts_controller.rb - About 1 hr to fix

      Method validate_payload has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def validate_payload
          schema = {
            "$schema" => "http://json-schema.org/draft-04/schema#",
            "title" => "Create Google Account message schema",
            "type" => "object",
      Severity: Minor
      Found in app/message_handlers/update_group_message_handler.rb - About 1 hr to fix

        Method api_v2_account_params has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def api_v2_account_params
            params.require(:account).permit(
              :uuid,
              :hruid,
              :id_soce,
        Severity: Minor
        Found in app/controllers/api/v2/accounts_controller.rb - About 1 hr to fix

          Method deep_hash_diff has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def deep_hash_diff(a, b)
                (a.keys | b.keys).inject({}) do |diff, k|
                  if a[k] != b[k]
                    if a[k].respond_to?(:deep_diff) && b[k].respond_to?(:deep_diff)
                      diff[k] = a[k].deep_diff(b[k])

          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