app/models/setup/task.rb
Class Task
has 49 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Task
include CenitScoped
include ClassHierarchyAware
include CrossOrigin::CenitDocument
include FieldsInspection
File task.rb
has 423 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module Setup
class Task
include CenitScoped
include ClassHierarchyAware
include CrossOrigin::CenitDocument
Method execute
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
Open
def execute(options = {})
task_desc = description.presence || "Task ##{id}"
if running? || !Cenit::Locker.lock(self)
notify(message: "Executing task ##{id} at #{Time.now} but it is already running")
else
- Read upRead up
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 execute
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def execute(options = {})
task_desc = description.presence || "Task ##{id}"
if running? || !Cenit::Locker.lock(self)
notify(message: "Executing task ##{id} at #{Time.now} but it is already running")
else
Method finish
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def finish(status, message, message_type, time)
self.status = status
thread_token.destroy if thread_token.present?
self.thread_token = nil
Thread.current[:task_token] = nil
Method finish
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def finish(status, message, message_type, time)
self.status = status
thread_token.destroy if thread_token.present?
self.thread_token = nil
Thread.current[:task_token] = nil
- Read upRead up
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"