sensu-plugins / sensu-plugins-mailgun

Sensu plugins for Mailgun
http://sensu-plugins.io
MIT License
0 stars 7 forks source link

PR for mailgun metric and check #2

Closed brendangibat closed 8 years ago

sstarcher commented 8 years ago

Rubocop

bin/check-mailgun-stats.rb:46:16: C: Use proc instead of Proc.new.
         proc: Proc.new { |d| d.split(",") }
               ^^^^^^^^
bin/check-mailgun-stats.rb:46:39: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
         proc: Proc.new { |d| d.split(",") }
                                      ^^^
bin/check-mailgun-stats.rb:52:16: C: Use proc instead of Proc.new.
         proc: Proc.new { |d| d.split(",") },
               ^^^^^^^^
bin/check-mailgun-stats.rb:52:39: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
         proc: Proc.new { |d| d.split(",") },
                                      ^^^
bin/check-mailgun-stats.rb:59:16: C: Use proc instead of Proc.new.
         proc: Proc.new { |d| d.split(",") },
               ^^^^^^^^
bin/check-mailgun-stats.rb:59:39: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
         proc: Proc.new { |d| d.split(",") },
                                      ^^^
bin/check-mailgun-stats.rb:118:29: C: Prefer !expression.nil? over expression != nil.
    if config[:day_of_week] != nil && curr_time.wday != config[:day_of_week]
                            ^^
bin/check-mailgun-stats.rb:122:30: C: Prefer !expression.nil? over expression != nil.
    if config[:day_of_month] != nil && curr_time.day != config[:day_of_month]
                             ^^
bin/check-mailgun-stats.rb:128:5: C: Use snake_case for variable names.
    totalSent = getTotalSent config[:domains], config[:mailgunKey], config[:events], config[:tags], config[:start_date]
    ^^^^^^^^^
bin/check-mailgun-stats.rb:139:7: C: Use snake_case for method names.
  def getTotalSent(domains, mailgunKey, events, tags, startDate)
      ^^^^^^^^^^^^
bin/check-mailgun-stats.rb:139:29: C: Use snake_case for variable names.
  def getTotalSent(domains, mailgunKey, events, tags, startDate)
                            ^^^^^^^^^^
bin/check-mailgun-stats.rb:139:55: C: Use snake_case for variable names.
  def getTotalSent(domains, mailgunKey, events, tags, startDate)
                                                      ^^^^^^^^^
bin/check-mailgun-stats.rb:142:9: C: Use snake_case for variable names.
        startDateString = !startDate.nil? ? "&#{startDate}" : ""
        ^^^^^^^^^^^^^^^
bin/check-mailgun-stats.rb:142:63: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        startDateString = !startDate.nil? ? "&#{startDate}" : ""
                                                              ^^
bin/check-mailgun-stats.rb:143:75: C: Space missing to the left of {.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1#{startDateString}")
                                                                          ^
bin/check-mailgun-stats.rb:143:75: C: Space between { and | missing.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1#{startDateString}")
                                                                          ^^
bin/check-mailgun-stats.rb:143:78: C: Space after closing | missing.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1#{startDateString}")
                                                                             ^
bin/check-mailgun-stats.rb:143:91: C: Space missing inside }.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1#{startDateString}")
                                                                                          ^
bin/check-mailgun-stats.rb:143:98: C: Prefer single-quoted strings inside interpolations.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1#{startDateString}")
                                                                                                 ^^^
bin/check-mailgun-stats.rb:153:7: C: Use 2 (not 4) spaces for indentation.
          critical "Error talking to Mailgun API #{e}"
      ^^^^
bin/check-mailgun-stats.rb:159:15: C: Prefer !expression.nil? over expression != nil.
      if item != nil
              ^^
bin/check-mailgun-stats.rb:160:12: C: Don't use parentheses around the condition of an if.
        if (tags != nil && !tags.empty? && !(tags.length == 1 && tags[0] == ""))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bin/check-mailgun-stats.rb:160:18: C: Prefer !expression.nil? over expression != nil.
        if (tags != nil && !tags.empty? && !(tags.length == 1 && tags[0] == ""))
                 ^^
bin/check-mailgun-stats.rb:160:77: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        if (tags != nil && !tags.empty? && !(tags.length == 1 && tags[0] == ""))
                                                                            ^^
bin/check-mailgun-stats.rb:161:9: C: Use 2 (not 4) spaces for indentation.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
        ^^^^
bin/check-mailgun-stats.rb:161:22: C: Space between { and | missing.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                     ^^
bin/check-mailgun-stats.rb:161:67: C: Space missing to the left of {.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                  ^
bin/check-mailgun-stats.rb:161:67: C: Space between { and | missing.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                  ^^
bin/check-mailgun-stats.rb:161:79: C: Space missing inside }.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                              ^
bin/check-mailgun-stats.rb:161:91: C: Space between { and | missing.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                                          ^^
bin/check-mailgun-stats.rb:161:92: C: Name inject block params |a, e|.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                                           ^^^^^^
bin/check-mailgun-stats.rb:161:104: C: Space missing inside }.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                                                       ^
bin/check-mailgun-stats.rb:163:9: C: Use 2 (not 4) spaces for indentation.
            item['items'][0]['total_count']
        ^^^^
bin/check-mailgun-stats.rb:169:22: C: Space between { and | missing.
    counts.inject(0) {|x, y| x + y}
                     ^^
bin/check-mailgun-stats.rb:169:23: C: Name inject block params |a, e|.
    counts.inject(0) {|x, y| x + y}
                      ^^^^^^
bin/check-mailgun-stats.rb:169:35: C: Space missing inside }.
    counts.inject(0) {|x, y| x + y}
                                  ^
bin/metrics-mailgun-stats.rb:68:16: C: Use proc instead of Proc.new.
         proc: Proc.new { |d| d.split(",") }
               ^^^^^^^^
bin/metrics-mailgun-stats.rb:68:39: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
         proc: Proc.new { |d| d.split(",") }
                                      ^^^
bin/metrics-mailgun-stats.rb:74:16: C: Use proc instead of Proc.new.
         proc: Proc.new { |d| d.split(",") },
               ^^^^^^^^
bin/metrics-mailgun-stats.rb:74:39: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
         proc: Proc.new { |d| d.split(",") },
                                      ^^^
bin/metrics-mailgun-stats.rb:81:16: C: Use proc instead of Proc.new.
         proc: Proc.new { |d| d.split(",") },
               ^^^^^^^^
bin/metrics-mailgun-stats.rb:81:39: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
         proc: Proc.new { |d| d.split(",") },
                                      ^^^
bin/metrics-mailgun-stats.rb:101:5: C: Use snake_case for variable names.
    totalSent = getTotalSent config[:domains], config[:mailgunKey], config[:events], config[:tags]
    ^^^^^^^^^
bin/metrics-mailgun-stats.rb:103:12: C: Prefer to_s over string interpolation.
    output "#{config[:scheme]}", totalSent, Time.now.utc
           ^^^^^^^^^^^^^^^^^^^^
bin/metrics-mailgun-stats.rb:108:7: C: Use snake_case for method names.
  def getTotalSent(domains, mailgunKey, events, tags)
      ^^^^^^^^^^^^
bin/metrics-mailgun-stats.rb:108:29: C: Use snake_case for variable names.
  def getTotalSent(domains, mailgunKey, events, tags)
                            ^^^^^^^^^^
bin/metrics-mailgun-stats.rb:111:75: C: Space missing to the left of {.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1")
                                                                          ^
bin/metrics-mailgun-stats.rb:111:75: C: Space between { and | missing.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1")
                                                                          ^^
bin/metrics-mailgun-stats.rb:111:78: C: Space after closing | missing.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1")
                                                                             ^
bin/metrics-mailgun-stats.rb:111:91: C: Space missing inside }.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1")
                                                                                          ^
bin/metrics-mailgun-stats.rb:111:98: C: Prefer single-quoted strings inside interpolations.
        uri = URI("https://api.mailgun.net/v3/#{domain}/stats?#{events.map{|e|"event=#{e}"}.join("&")}&limit=1")
                                                                                                 ^^^
bin/metrics-mailgun-stats.rb:120:7: C: Use 2 (not 4) spaces for indentation.
          critical "Error talking to Mailgun API #{e}"
      ^^^^
bin/metrics-mailgun-stats.rb:126:12: C: Prefer to_s over string interpolation.
      puts "#{item}"
           ^^^^^^^^^
bin/metrics-mailgun-stats.rb:127:15: C: Prefer !expression.nil? over expression != nil.
      if item != nil
              ^^
bin/metrics-mailgun-stats.rb:128:12: C: Don't use parentheses around the condition of an if.
        if (tags != nil && !tags.empty? && !(tags.length == 1 && tags[0] == ""))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bin/metrics-mailgun-stats.rb:128:18: C: Prefer !expression.nil? over expression != nil.
        if (tags != nil && !tags.empty? && !(tags.length == 1 && tags[0] == ""))
                 ^^
bin/metrics-mailgun-stats.rb:128:77: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        if (tags != nil && !tags.empty? && !(tags.length == 1 && tags[0] == ""))
                                                                            ^^
bin/metrics-mailgun-stats.rb:129:9: C: Use 2 (not 4) spaces for indentation.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
        ^^^^
bin/metrics-mailgun-stats.rb:129:22: C: Space between { and | missing.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                     ^^
bin/metrics-mailgun-stats.rb:129:67: C: Space missing to the left of {.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                  ^
bin/metrics-mailgun-stats.rb:129:67: C: Space between { and | missing.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                  ^^
bin/metrics-mailgun-stats.rb:129:79: C: Space missing inside }.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                              ^
bin/metrics-mailgun-stats.rb:129:91: C: Space between { and | missing.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                                          ^^
bin/metrics-mailgun-stats.rb:129:92: C: Name inject block params |a, e|.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                                           ^^^^^^
bin/metrics-mailgun-stats.rb:129:104: C: Space missing inside }.
            tags.map {|tag| item['items'][0]['tags'][tag] }.select{|v| !v.nil?}.inject(0) {|x, y| x + y}
                                                                                                       ^
bin/metrics-mailgun-stats.rb:131:9: C: Use 2 (not 4) spaces for indentation.
            item['items'][0]['total_count']
        ^^^^
bin/metrics-mailgun-stats.rb:137:22: C: Space between { and | missing.
    counts.inject(0) {|x, y| x + y}
                     ^^
bin/metrics-mailgun-stats.rb:137:23: C: Name inject block params |a, e|.
    counts.inject(0) {|x, y| x + y}
                      ^^^^^^
bin/metrics-mailgun-stats.rb:137:35: C: Space missing inside }.
    counts.inject(0) {|x, y| x + y}
                                  ^
lib/sensu-plugins-mailgun/common.rb:9:5: C: Use Aws.config[:credentials] = Aws::Credentials.new(config[:aws_access_key], config[:aws_secret_access_key]) instead of `Aws.config.update(
      credentials: Aws::Credentials.new(config[:aws_access_key], config[:aws_secret_access_key])
    )`.
    Aws.config.update(
    ^^^^^^^^^^^^^^^^^^
lib/sensu-plugins-mailgun/common.rb:19:34: C: Prefer !expression.nil? over expression != nil.
    if config[:s3_config_bucket] != nil && config[:s3_config_key] != nil
                                 ^^
lib/sensu-plugins-mailgun/common.rb:19:67: C: Prefer !expression.nil? over expression != nil.
    if config[:s3_config_bucket] != nil && config[:s3_config_key] != nil
                                                                  ^^
lib/sensu-plugins-mailgun/common.rb:23:36: C: Space missing after colon.
        resp = s3.get_object(bucket:config[:s3_config_bucket], key:config[:s3_config_key])
                                   ^
lib/sensu-plugins-mailgun/common.rb:23:67: C: Space missing after colon.
        resp = s3.get_object(bucket:config[:s3_config_bucket], key:config[:s3_config_key])
                                                                  ^
lib/sensu-plugins-mailgun/common.rb:26:17: W: Useless assignment to variable - e.
      rescue => e
                ^
lib/sensu-plugins-mailgun/common.rb:27:18: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        critical "Error getting config file from s3"
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/sensu-plugins-mailgun/common.rb:33:5: C: Redundant begin block detected.
    begin
    ^^^^^
lib/sensu-plugins-mailgun/common.rb:35:9: C: Align the parameters of a method call if they span more than one line.
        timeout: config[:sensu_timeout],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/sensu-plugins-mailgun/common.rb:37:17: C: Space missing after colon.
        password:config[:sensu_password])
eheydrick commented 8 years ago

Hi @brendangibat, I'd love to merge your plugin. Can you take a look at the rubocop issues.

sstarcher commented 8 years ago

I merged and fixed the rubocop issues

brendangibat commented 8 years ago

@sstarcher thanks!

brendangibat commented 8 years ago

Sorry @sstarcher and @eheydrick - this PR completely fell off my radar.