gadzorg/gram2_api_server

View on GitHub

Showing 16 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          def add_to_group
            @group = MasterData::Group.find_by(uuid: params[:group_uuid])
            @groups = @account.groups
            authorize @group, :edit?
        
        
        Severity: Major
        Found in app/controllers/api/v2/accounts_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/api/v2/accounts_controller.rb on lines 222..238

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 59.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          def add_role
            @role = MasterData::Role.find_by!(uuid: params[:role_uuid])
            @roles = @account.roles
            authorize @role, :edit?
        
        
        Severity: Major
        Found in app/controllers/api/v2/accounts_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/api/v2/accounts_controller.rb on lines 183..199

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 59.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def create
              @role = MasterData::Role.new(api_v2_role_params)
              authorize @role, :create?
          
              respond_to do |format|
          Severity: Major
          Found in app/controllers/api/v2/roles_controller.rb and 1 other location - About 1 hr to fix
          app/controllers/api/v2/groups_controller.rb on lines 49..63

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def create
              @group = MasterData::Group.new(group_params)
              authorize @group, :create?
          
              respond_to do |format|
          Severity: Major
          Found in app/controllers/api/v2/groups_controller.rb and 1 other location - About 1 hr to fix
          app/controllers/api/v2/roles_controller.rb on lines 43..53

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def update
              authorize @group, :edit?
              respond_to do |format|
                if @group.update(group_params)
                  format.html do
          Severity: Minor
          Found in app/controllers/api/v2/groups_controller.rb and 1 other location - About 55 mins to fix
          app/controllers/api/v2/roles_controller.rb on lines 60..68

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 46.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def update
              authorize @role, :edit?
              respond_to do |format|
                if @role.update(api_v2_role_params)
                  format.html { render :show, notice: "Role was successfully updated." }
          Severity: Minor
          Found in app/controllers/api/v2/roles_controller.rb and 1 other location - About 55 mins to fix
          app/controllers/api/v2/groups_controller.rb on lines 70..82

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 46.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def remove_role
              client = Client.find(params[:client_id])
              authorize client, :edit?
              role_name = params[:role_name]
              ressource = params[:ressource]
          Severity: Minor
          Found in app/controllers/clients_controller.rb and 1 other location - About 35 mins to fix
          app/controllers/clients_controller.rb on lines 81..89

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 36.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def add_role
              client = Client.find(params[:client_id])
              authorize client, :edit?
              role_name = params[:role_name]
              ressource = params[:ressource]
          Severity: Minor
          Found in app/controllers/clients_controller.rb and 1 other location - About 35 mins to fix
          app/controllers/clients_controller.rb on lines 91..99

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 36.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def revoke_role
              role = @account.roles.find_by!(uuid: params[:role_uuid])
              authorize role, :edit?
          
              respond_to do |format|
          Severity: Minor
          Found in app/controllers/api/v2/accounts_controller.rb and 1 other location - About 35 mins to fix
          app/controllers/api/v2/accounts_controller.rb on lines 204..214

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            def remove_from_group
              group = @account.groups.find_by(uuid: params[:group_uuid])
              authorize group, :edit?
              respond_to do |format|
                if @account.remove_from_group group
          Severity: Minor
          Found in app/controllers/api/v2/accounts_controller.rb and 1 other location - About 35 mins to fix
          app/controllers/api/v2/accounts_controller.rb on lines 243..253

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language