gitshowcase/gitshowcase

View on GitHub
app/services/snapshot_service.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class has too many lines. [152/100]
Open

class SnapshotService < ApplicationService
  # Constraints
  TYPE_TOTAL = :total
  TYPE_DAILY = :daily

Severity: Minor
Found in app/services/snapshot_service.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class SnapshotService has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class SnapshotService < ApplicationService
  # Constraints
  TYPE_TOTAL = :total
  TYPE_DAILY = :daily

Severity: Minor
Found in app/services/snapshot_service.rb - About 4 hrs to fix

    Line is too long. [108/80]
    Open

        @invitation_counts[6] = @invitation_counts.map { |invitations, count| invitations >= 6 ? count : 0 }.sum
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Freeze mutable objects assigned to constants.
    Open

      INVITATION_FUNNEL = [:count_zero_invitations,
                           :count_one_invitations,
                           :count_two_invitations,
                           :count_three_invitations,
                           :count_four_invitations,
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Space inside } missing.
    Open

        {where: where, values: values}
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

    Example: EnforcedStyle: space

    # The `space` style enforces that hash literals have
    # surrounding space.
    
    # bad
    h = {a: 1, b: 2}
    
    # good
    h = { a: 1, b: 2 }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that hash literals have
    # no surrounding space.
    
    # bad
    h = { a: 1, b: 2 }
    
    # good
    h = {a: 1, b: 2}

    Example: EnforcedStyle: compact

    # The `compact` style normally requires a space inside
    # hash braces, with the exception that successive left
    # braces or right braces are collapsed together in nested hashes.
    
    # bad
    h = { a: { b: 2 } }
    
    # good
    h = { a: { b: 2 }}

    Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is.
    Open

            general(TYPE_TOTAL),
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop checks the indentation of the first element in an array literal where the opening bracket and the first element are on separate lines. The other elements' indentations are handled by the AlignArray cop.

    By default, array literals that are arguments in a method call with parentheses, and where the opening square bracket of the array is on the same line as the opening parenthesis of the method call, shall have their first element indented one step (two spaces) more than the position inside the opening parenthesis.

    Other array literals shall have their first element indented one step more than the start of the line where the opening square bracket is.

    This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_brackets'. Here are examples:

    Example: EnforcedStyle: specialinsideparentheses (default)

    # The `special_inside_parentheses` style enforces that the first
    # element in an array literal where the opening bracket and first
    # element are on seprate lines is indented one step (two spaces) more
    # than the position inside the opening parenthesis.
    
    #bad
    array = [
      :value
    ]
    and_in_a_method_call([
      :no_difference
                         ])
    
    #good
    array = [
      :value
    ]
    but_in_a_method_call([
                           :its_like_this
                         ])

    Example: EnforcedStyle: consistent

    # The `consistent` style enforces that the first element in an array
    # literal where the opening bracket and the first element are on
    # seprate lines is indented the same as an array literal which is not
    # defined inside a method call.
    
    #bad
    # consistent
    array = [
      :value
    ]
    but_in_a_method_call([
                           :its_like_this
    ])
    
    #good
    array = [
      :value
    ]
    and_in_a_method_call([
      :no_difference
    ])

    Example: EnforcedStyle: align_brackets

    # The `align_brackets` style enforces that the opening and closing
    # brackets are indented to the same position.
    
    #bad
    # align_brackets
    and_now_for_something = [
                              :completely_different
    ]
    
    #good
    # align_brackets
    and_now_for_something = [
                              :completely_different
                            ]

    Freeze mutable objects assigned to constants.
    Open

      INVITATION = [:count_invitations]
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Line is too long. [137/80]
    Open

        @queries["#{model.name}-#{type}"] ||= model.where("DATE(#{model.table_name}.created_at) #{type == TYPE_TOTAL ? '<=' : '='} ?", @date)
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Line is too long. [125/80]
    Open

        @invitation_counts = Hash[grouped_invitations.group_by(&:invitees).map { |invitations, rows| [invitations, rows.count] }]
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Use %i or %I for an array of symbols.
    Open

      USER_COMPLETENESS = [:total_user_completeness,
                           :count_user_weak_completeness,
                           :count_user_medium_completeness,
                           :count_user_strong_completeness,
                           :count_user_very_strong_completeness]
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop can check for array literals made up of symbols that are not using the %i() syntax.

    Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %i[foo bar baz]
    
    # bad
    [:foo, :bar, :baz]

    Example: EnforcedStyle: brackets

    # good
    [:foo, :bar, :baz]
    
    # bad
    %i[foo bar baz]

    Space inside } missing.
    Open

        Snapshot.new({date: @date}.merge(all))
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

    Example: EnforcedStyle: space

    # The `space` style enforces that hash literals have
    # surrounding space.
    
    # bad
    h = {a: 1, b: 2}
    
    # good
    h = { a: 1, b: 2 }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that hash literals have
    # no surrounding space.
    
    # bad
    h = { a: 1, b: 2 }
    
    # good
    h = {a: 1, b: 2}

    Example: EnforcedStyle: compact

    # The `compact` style normally requires a space inside
    # hash braces, with the exception that successive left
    # braces or right braces are collapsed together in nested hashes.
    
    # bad
    h = { a: { b: 2 } }
    
    # good
    h = { a: { b: 2 }}

    Space inside { missing.
    Open

        {where: where, values: values}
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

    Example: EnforcedStyle: space

    # The `space` style enforces that hash literals have
    # surrounding space.
    
    # bad
    h = {a: 1, b: 2}
    
    # good
    h = { a: 1, b: 2 }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that hash literals have
    # no surrounding space.
    
    # bad
    h = { a: 1, b: 2 }
    
    # good
    h = {a: 1, b: 2}

    Example: EnforcedStyle: compact

    # The `compact` style normally requires a space inside
    # hash braces, with the exception that successive left
    # braces or right braces are collapsed together in nested hashes.
    
    # bad
    h = { a: { b: 2 } }
    
    # good
    h = { a: { b: 2 }}

    Line is too long. [125/80]
    Open

        grouped_invitations = query(Invitation, type).joins(:inviter).select('count(users.id) as invitees').group('users.id').all
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Line is too long. [81/80]
    Open

        others = invitation_counts(type).map { |key, value| key > 6 ? 0 : value }.sum
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Use %i or %I for an array of symbols.
    Open

      GENERAL = [:count_users, :count_projects, :count_domains]
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop can check for array literals made up of symbols that are not using the %i() syntax.

    Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %i[foo bar baz]
    
    # bad
    [:foo, :bar, :baz]

    Example: EnforcedStyle: brackets

    # good
    [:foo, :bar, :baz]
    
    # bad
    %i[foo bar baz]

    Space inside { missing.
    Open

        Snapshot.new({date: @date}.merge(all))
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

    Example: EnforcedStyle: space

    # The `space` style enforces that hash literals have
    # surrounding space.
    
    # bad
    h = {a: 1, b: 2}
    
    # good
    h = { a: 1, b: 2 }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that hash literals have
    # no surrounding space.
    
    # bad
    h = { a: 1, b: 2 }
    
    # good
    h = {a: 1, b: 2}

    Example: EnforcedStyle: compact

    # The `compact` style normally requires a space inside
    # hash braces, with the exception that successive left
    # braces or right braces are collapsed together in nested hashes.
    
    # bad
    h = { a: { b: 2 } }
    
    # good
    h = { a: { b: 2 }}

    Missing top-level class documentation comment.
    Open

    class SnapshotService < ApplicationService
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    Freeze mutable objects assigned to constants.
    Open

      GENERAL = [:count_users, :count_projects, :count_domains]
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Use %i or %I for an array of symbols.
    Open

      INVITATION_FUNNEL = [:count_zero_invitations,
                           :count_one_invitations,
                           :count_two_invitations,
                           :count_three_invitations,
                           :count_four_invitations,
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop can check for array literals made up of symbols that are not using the %i() syntax.

    Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %i[foo bar baz]
    
    # bad
    [:foo, :bar, :baz]

    Example: EnforcedStyle: brackets

    # good
    [:foo, :bar, :baz]
    
    # bad
    %i[foo bar baz]

    Freeze mutable objects assigned to constants.
    Open

      USER_COMPLETENESS = [:total_user_completeness,
                           :count_user_weak_completeness,
                           :count_user_medium_completeness,
                           :count_user_strong_completeness,
                           :count_user_very_strong_completeness]
    Severity: Minor
    Found in app/services/snapshot_service.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    There are no issues that match your filters.

    Category
    Status