app/workers/dhis2_snapshot_worker.rb

Summary

Maintainability
A
35 mins
Test Coverage
A
100%

Method has too many lines. [21/10]
Open

  def compact_and_store(project, kind, now, data, dhis2_version)
    month = now.month
    year = now.year
    new_snapshot = false
    snapshot = project.project_anchor.dhis2_snapshots.find_or_initialize_by(

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

Method compact_and_store has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def compact_and_store(project, kind, now, data, dhis2_version)
Severity: Minor
Found in app/workers/dhis2_snapshot_worker.rb - About 35 mins to fix

    Do not write to stdout. Use Rails's logger if you want to log.
    Open

        puts "Snapshoting for #{project_anchor.projects.first.name} : #{now}"

    This cop checks for the use of output calls like puts and print

    Example:

    # bad
    puts 'A debug message'
    pp 'A debug message'
    print 'A debug message'
    
    # good
    Rails.logger.debug 'A debug message'

    Do not write to stdout. Use Rails's logger if you want to log.
    Open

        puts "#{Time.new} \t#{message} #{kind} total time : #{Time.new - start})"

    This cop checks for the use of output calls like puts and print

    Example:

    # bad
    puts 'A debug message'
    pp 'A debug message'
    print 'A debug message'
    
    # good
    Rails.logger.debug 'A debug message'

    Align the elements of a hash literal if they span more than one line.
    Open

        threshold:   { limit: 3, period: 2.minutes }

    Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:

    - key (left align keys, one space before hash rockets and values)
    - separator (align hash rockets and colons, right align keys)
    - table (left align keys, hash rockets, and values)

    The treatment of hashes passed as the last argument to a method call can also be configured. The options are:

    - always_inspect
    - always_ignore
    - ignore_implicit (without curly braces)

    Alternatively you can specify multiple allowed styles. That's done by passing a list of styles to EnforcedStyles.

    Example: EnforcedHashRocketStyle: key (default)

    # bad
    {
      :foo => bar,
       :ba => baz
    }
    {
      :foo => bar,
      :ba  => baz
    }
    
    # good
    {
      :foo => bar,
      :ba => baz
    }

    Example: EnforcedHashRocketStyle: separator

    # bad
    {
      :foo => bar,
      :ba => baz
    }
    {
      :foo => bar,
      :ba  => baz
    }
    
    # good
    {
      :foo => bar,
       :ba => baz
    }

    Example: EnforcedHashRocketStyle: table

    # bad
    {
      :foo => bar,
       :ba => baz
    }
    
    # good
    {
      :foo => bar,
      :ba  => baz
    }

    Example: EnforcedColonStyle: key (default)

    # bad
    {
      foo: bar,
       ba: baz
    }
    {
      foo: bar,
      ba:  baz
    }
    
    # good
    {
      foo: bar,
      ba: baz
    }

    Example: EnforcedColonStyle: separator

    # bad
    {
      foo: bar,
      ba: baz
    }
    
    # good
    {
      foo: bar,
       ba: baz
    }

    Example: EnforcedColonStyle: table

    # bad
    {
      foo: bar,
      ba: baz
    }
    
    # good
    {
      foo: bar,
      ba:  baz
    }

    Example: EnforcedLastArgumentHashStyle: always_inspect (default)

    # Inspect both implicit and explicit hashes.
    
    # bad
    do_something(foo: 1,
      bar: 2)
    
    # bad
    do_something({foo: 1,
      bar: 2})
    
    # good
    do_something(foo: 1,
                 bar: 2)
    
    # good
    do_something(
      foo: 1,
      bar: 2
    )
    
    # good
    do_something({foo: 1,
                  bar: 2})
    
    # good
    do_something({
      foo: 1,
      bar: 2
    })

    Example: EnforcedLastArgumentHashStyle: always_ignore

    # Ignore both implicit and explicit hashes.
    
    # good
    do_something(foo: 1,
      bar: 2)
    
    # good
    do_something({foo: 1,
      bar: 2})

    Example: EnforcedLastArgumentHashStyle: ignore_implicit

    # Ignore only implicit hashes.
    
    # bad
    do_something({foo: 1,
      bar: 2})
    
    # good
    do_something(foo: 1,
      bar: 2)

    Example: EnforcedLastArgumentHashStyle: ignore_explicit

    # Ignore only explicit hashes.
    
    # bad
    do_something(foo: 1,
      bar: 2)
    
    # good
    do_something({foo: 1,
      bar: 2})

    Do not use Time.new without zone. Use one of Time.zone.now, Time.current, Time.new.in_time_zone, Time.new.utc, Time.new.getlocal, Time.new.xmlschema, Time.new.iso8601, Time.new.jisx0301, Time.new.rfc3339, Time.new.httpdate, Time.new.to_i, Time.new.to_f instead.
    Open

        puts "#{Time.new} \t#{message} #{kind} total time : #{Time.new - start})"

    This cop checks for the use of Time methods without zone.

    Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

    Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

    When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

    Example: EnforcedStyle: strict

    # `strict` means that `Time` should be used with `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # bad
    Time.current
    Time.at(timestamp).in_time_zone
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')

    Example: EnforcedStyle: flexible (default)

    # `flexible` allows usage of `in_time_zone` instead of `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')
    
    # good
    Time.current
    Time.at(timestamp).in_time_zone

    Align the elements of a hash literal if they span more than one line.
    Open

          kind:  kind,

    Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:

    - key (left align keys, one space before hash rockets and values)
    - separator (align hash rockets and colons, right align keys)
    - table (left align keys, hash rockets, and values)

    The treatment of hashes passed as the last argument to a method call can also be configured. The options are:

    - always_inspect
    - always_ignore
    - ignore_implicit (without curly braces)

    Alternatively you can specify multiple allowed styles. That's done by passing a list of styles to EnforcedStyles.

    Example: EnforcedHashRocketStyle: key (default)

    # bad
    {
      :foo => bar,
       :ba => baz
    }
    {
      :foo => bar,
      :ba  => baz
    }
    
    # good
    {
      :foo => bar,
      :ba => baz
    }

    Example: EnforcedHashRocketStyle: separator

    # bad
    {
      :foo => bar,
      :ba => baz
    }
    {
      :foo => bar,
      :ba  => baz
    }
    
    # good
    {
      :foo => bar,
       :ba => baz
    }

    Example: EnforcedHashRocketStyle: table

    # bad
    {
      :foo => bar,
       :ba => baz
    }
    
    # good
    {
      :foo => bar,
      :ba  => baz
    }

    Example: EnforcedColonStyle: key (default)

    # bad
    {
      foo: bar,
       ba: baz
    }
    {
      foo: bar,
      ba:  baz
    }
    
    # good
    {
      foo: bar,
      ba: baz
    }

    Example: EnforcedColonStyle: separator

    # bad
    {
      foo: bar,
      ba: baz
    }
    
    # good
    {
      foo: bar,
       ba: baz
    }

    Example: EnforcedColonStyle: table

    # bad
    {
      foo: bar,
      ba: baz
    }
    
    # good
    {
      foo: bar,
      ba:  baz
    }

    Example: EnforcedLastArgumentHashStyle: always_inspect (default)

    # Inspect both implicit and explicit hashes.
    
    # bad
    do_something(foo: 1,
      bar: 2)
    
    # bad
    do_something({foo: 1,
      bar: 2})
    
    # good
    do_something(foo: 1,
                 bar: 2)
    
    # good
    do_something(
      foo: 1,
      bar: 2
    )
    
    # good
    do_something({foo: 1,
                  bar: 2})
    
    # good
    do_something({
      foo: 1,
      bar: 2
    })

    Example: EnforcedLastArgumentHashStyle: always_ignore

    # Ignore both implicit and explicit hashes.
    
    # good
    do_something(foo: 1,
      bar: 2)
    
    # good
    do_something({foo: 1,
      bar: 2})

    Example: EnforcedLastArgumentHashStyle: ignore_implicit

    # Ignore only implicit hashes.
    
    # bad
    do_something({foo: 1,
      bar: 2})
    
    # good
    do_something(foo: 1,
      bar: 2)

    Example: EnforcedLastArgumentHashStyle: ignore_explicit

    # Ignore only explicit hashes.
    
    # bad
    do_something(foo: 1,
      bar: 2)
    
    # good
    do_something({foo: 1,
      bar: 2})

    Align the elements of a hash literal if they span more than one line.
    Open

          year:  year

    Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:

    - key (left align keys, one space before hash rockets and values)
    - separator (align hash rockets and colons, right align keys)
    - table (left align keys, hash rockets, and values)

    The treatment of hashes passed as the last argument to a method call can also be configured. The options are:

    - always_inspect
    - always_ignore
    - ignore_implicit (without curly braces)

    Alternatively you can specify multiple allowed styles. That's done by passing a list of styles to EnforcedStyles.

    Example: EnforcedHashRocketStyle: key (default)

    # bad
    {
      :foo => bar,
       :ba => baz
    }
    {
      :foo => bar,
      :ba  => baz
    }
    
    # good
    {
      :foo => bar,
      :ba => baz
    }

    Example: EnforcedHashRocketStyle: separator

    # bad
    {
      :foo => bar,
      :ba => baz
    }
    {
      :foo => bar,
      :ba  => baz
    }
    
    # good
    {
      :foo => bar,
       :ba => baz
    }

    Example: EnforcedHashRocketStyle: table

    # bad
    {
      :foo => bar,
       :ba => baz
    }
    
    # good
    {
      :foo => bar,
      :ba  => baz
    }

    Example: EnforcedColonStyle: key (default)

    # bad
    {
      foo: bar,
       ba: baz
    }
    {
      foo: bar,
      ba:  baz
    }
    
    # good
    {
      foo: bar,
      ba: baz
    }

    Example: EnforcedColonStyle: separator

    # bad
    {
      foo: bar,
      ba: baz
    }
    
    # good
    {
      foo: bar,
       ba: baz
    }

    Example: EnforcedColonStyle: table

    # bad
    {
      foo: bar,
      ba: baz
    }
    
    # good
    {
      foo: bar,
      ba:  baz
    }

    Example: EnforcedLastArgumentHashStyle: always_inspect (default)

    # Inspect both implicit and explicit hashes.
    
    # bad
    do_something(foo: 1,
      bar: 2)
    
    # bad
    do_something({foo: 1,
      bar: 2})
    
    # good
    do_something(foo: 1,
                 bar: 2)
    
    # good
    do_something(
      foo: 1,
      bar: 2
    )
    
    # good
    do_something({foo: 1,
                  bar: 2})
    
    # good
    do_something({
      foo: 1,
      bar: 2
    })

    Example: EnforcedLastArgumentHashStyle: always_ignore

    # Ignore both implicit and explicit hashes.
    
    # good
    do_something(foo: 1,
      bar: 2)
    
    # good
    do_something({foo: 1,
      bar: 2})

    Example: EnforcedLastArgumentHashStyle: ignore_implicit

    # Ignore only implicit hashes.
    
    # bad
    do_something({foo: 1,
      bar: 2})
    
    # good
    do_something(foo: 1,
      bar: 2)

    Example: EnforcedLastArgumentHashStyle: ignore_explicit

    # Ignore only explicit hashes.
    
    # bad
    do_something(foo: 1,
      bar: 2)
    
    # good
    do_something({foo: 1,
      bar: 2})

    Line is too long. [195/100]
    Open

        Rails.logger.info "Dhis2SnapshotWorker #{kind} : for project anchor #{new_snapshot ? 'created' : 'updated'} #{year} #{month} : #{project.project_anchor.id} #{project.name} #{data.size} done!"

    Do not use Time.new without zone. Use one of Time.zone.now, Time.current, Time.new.in_time_zone, Time.new.utc, Time.new.getlocal, Time.new.xmlschema, Time.new.iso8601, Time.new.jisx0301, Time.new.rfc3339, Time.new.httpdate, Time.new.to_i, Time.new.to_f instead.
    Open

        start = Time.new

    This cop checks for the use of Time methods without zone.

    Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

    Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

    When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

    Example: EnforcedStyle: strict

    # `strict` means that `Time` should be used with `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # bad
    Time.current
    Time.at(timestamp).in_time_zone
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')

    Example: EnforcedStyle: flexible (default)

    # `flexible` allows usage of `in_time_zone` instead of `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')
    
    # good
    Time.current
    Time.at(timestamp).in_time_zone

    Line is too long. [101/100]
    Open

          Fetchers::GenericSnapshotFetcher.new(fields: "id,name,code,categoryOptionCombos[id,name,code]")

    Do not use Time.new without zone. Use one of Time.zone.now, Time.current, Time.new.in_time_zone, Time.new.utc, Time.new.getlocal, Time.new.xmlschema, Time.new.iso8601, Time.new.jisx0301, Time.new.rfc3339, Time.new.httpdate, Time.new.to_i, Time.new.to_f instead.
    Open

        puts "#{Time.new} \t#{message} #{kind} total time : #{Time.new - start})"

    This cop checks for the use of Time methods without zone.

    Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

    Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

    When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

    Example: EnforcedStyle: strict

    # `strict` means that `Time` should be used with `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # bad
    Time.current
    Time.at(timestamp).in_time_zone
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')

    Example: EnforcedStyle: flexible (default)

    # `flexible` allows usage of `in_time_zone` instead of `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')
    
    # good
    Time.current
    Time.at(timestamp).in_time_zone

    There are no issues that match your filters.

    Category
    Status