File processing_queries.rb
has 569 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'active_support/core_ext/array/wrap'
module Sipity
module Queries
# Welcome intrepid developer. You have stumbled into some complex data
- Create a ticketCreate a ticket
Method scope_processing_entities_for_the_user_and_proxy_for_type
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scope_processing_entities_for_the_user_and_proxy_for_type(criteria:)
proxy_for_type = PowerConverter.convert(criteria.proxy_for_type, to: :polymorphic_type)
entities = Models::Processing::Entity.arel_table
strategy_state_actions = Models::Processing::StrategyStateAction.arel_table
- Create a ticketCreate a ticket
Method scope_users_for_entity_and_roles
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scope_users_for_entity_and_roles(entity:, roles:)
entity = Conversions::ConvertToProcessingEntity.call(entity)
role_ids = Array.wrap(roles).map { |role| Conversions::ConvertToRole.call(role).id }
group_polymorphic_type = PowerConverter.convert(Models::Group, to: :polymorphic_type)
user_polymorphic_type = PowerConverter.convert(User, to: :polymorphic_type)
- Create a ticketCreate a ticket
Method scope_permitted_entity_strategy_actions_for_current_state
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scope_permitted_entity_strategy_actions_for_current_state(user:, entity:)
action_scope = scope_permitted_without_concern_for_repetition_entity_strategy_actions_for_current_state(user: user, entity: entity)
entity = Conversions::ConvertToProcessingEntity.call(entity)
actor = Conversions::ConvertToProcessingActor.call(user)
- Create a ticketCreate a ticket
Method scope_actors_associated_with_entity_and_role
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scope_actors_associated_with_entity_and_role(entity:, role:)
entity = Conversions::ConvertToProcessingEntity.call(entity)
role = Conversions::ConvertToRole.call(role)
strategy_roles = Models::Processing::StrategyRole.arel_table
strategy_responsibilities = Models::Processing::StrategyResponsibility.arel_table
- Create a ticketCreate a ticket
Method collaborators_that_have_taken_the_action_on_the_entity
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def collaborators_that_have_taken_the_action_on_the_entity(entity:, actions:)
entity = Conversions::ConvertToProcessingEntity.call(entity)
collaborators = Models::Collaborator.arel_table
users = User.arel_table
users_scope = users_that_have_taken_the_action_on_the_entity(entity: entity, actions: actions)
- Create a ticketCreate a ticket
Method scope_processing_entities_for_the_user_and_proxy_for_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def scope_processing_entities_for_the_user_and_proxy_for_type(criteria:)
proxy_for_type = PowerConverter.convert(criteria.proxy_for_type, to: :polymorphic_type)
entities = Models::Processing::Entity.arel_table
strategy_state_actions = Models::Processing::StrategyStateAction.arel_table
- Read upRead up
- Create a ticketCreate a ticket
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
actors_select_manager = actors.project(
:*,
Arel.sql("'#{Models::Processing::Actor::ENTITY_LEVEL_ACTOR_PROCESSING_RELATIONSHIP}'").as('actor_processing_relationship')
).where(
actors[:id].in(
- Read upRead up
- Create a ticketCreate a ticket
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 48.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
actors.project(
:*,
Arel.sql("'#{Models::Processing::Actor::STRATEGY_LEVEL_ACTOR_PROCESSING_RELATIONSHIP}'").as('actor_processing_relationship')
).where(
actors[:id].in(
- Read upRead up
- Create a ticketCreate a ticket
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 48.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
completed_guarded_actions_subquery = action_prereqs.arel_table.project(
action_prereqs.arel_table[:guarded_strategy_action_id]
).where(
action_prereqs.arel_table[:prerequisite_strategy_action_id].in(
actions_that_occurred.arel_table.project(actions_that_occurred.arel_table[:id]).
- Read upRead up
- Create a ticketCreate a ticket
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 25.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
permissions.arel_table.project(
permissions.arel_table[:strategy_state_action_id]
).where(
permissions.arel_table[:strategy_role_id].in(
role_scope.arel_table.project(role_scope.arel_table[:id]).where(
- Read upRead up
- Create a ticketCreate a ticket
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 25.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76