loomio/loomio

View on GitHub
app/services/task_service.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method update_model has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.update_model(model, tasks_data)
    uids = tasks_data.map {|t| t[:uid] }
    existing_uids = model.tasks.pluck(:uid)
    new_uids = uids - existing_uids
    removed_uids = existing_uids - uids
Severity: Minor
Found in app/services/task_service.rb - About 1 hr to fix

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

      def self.update_done(task, actor, done)
    
        task.done = done
        task.done_at = (done && Time.now) || nil
        task.doer = (done && actor) || nil
    Severity: Minor
    Found in app/services/task_service.rb - About 55 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_model has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.update_model(model, tasks_data)
        uids = tasks_data.map {|t| t[:uid] }
        existing_uids = model.tasks.pluck(:uid)
        new_uids = uids - existing_uids
        removed_uids = existing_uids - uids
    Severity: Minor
    Found in app/services/task_service.rb - About 45 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 parse_tasks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.parse_tasks(rich_text, author)
        Nokogiri::HTML::fragment(rich_text).search('li[data-type="taskItem"]').map do |el|
          identifiers = Nokogiri::HTML::fragment(el).
                        search("span[data-mention-id]").map do |el|
                          el['data-mention-id']
    Severity: Minor
    Found in app/services/task_service.rb - About 45 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