octobox/octobox

View on GitHub
app/models/subject.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Subject has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

class Subject < ApplicationRecord
  has_many :notifications, foreign_key: :subject_url, primary_key: :url
  has_many :labels, dependent: :delete_all
  has_many :users, through: :notifications
  has_many :comments, dependent: :delete_all
Severity: Minor
Found in app/models/subject.rb - About 3 hrs to fix

    Method update_comments has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_comments
        remote_comments = download_comments
        if pull_request? && remote_comments
          remote_comments.concat download_reviews
          remote_comments.concat download_review_comments
    Severity: Minor
    Found in app/models/subject.rb - About 1 hr 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 sync has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def sync(remote_subject)
        update({
          repository_full_name: extract_full_name_from_remote_subject(remote_subject),
          github_id: remote_subject['id'],
          state: remote_subject['merged_at'].present? ? 'merged' : remote_subject['state'],
    Severity: Minor
    Found in app/models/subject.rb - About 1 hr 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 download_reviews has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def download_reviews
        return [] unless github_client && pull_request?
        reviews = github_client.get(url + '/reviews', since: comments.order('created_at ASC').last.try(:created_at))
        return [] unless reviews.present?
        reviews.map { |review|
    Severity: Minor
    Found in app/models/subject.rb - About 1 hr 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_labels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_labels(remote_labels)
        existing_labels = labels.to_a
        remote_labels.each do |l|
          label = labels.find_by_github_id(l['id'])
          if label.nil?
    Severity: Minor
    Found in app/models/subject.rb - About 35 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_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_status
        if sha.present?
          remote_status = download_status
          if remote_status.present?
            self.status = assign_status(remote_status)
    Severity: Minor
    Found in app/models/subject.rb - About 25 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