Skip to content

Commit

Permalink
Merge pull request #23 from airbnb/add-static-analysis-rebased
Browse files Browse the repository at this point in the history
[rubocop] Add static analysis
  • Loading branch information
jimmyngo committed Jul 10, 2017
2 parents 234f933 + adf4689 commit 91fcd73
Show file tree
Hide file tree
Showing 38 changed files with 705 additions and 667 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# REVIEWERS airbnb/security airbnb/rubocop

inherit_from:
- .rubocop_todo.yml
83 changes: 83 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 50000`
# on 2017-06-05 13:58:15 -0700 using RuboCop version 0.41.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

Metrics/AbcSize:
Enabled: false

Metrics/ClassLength:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false
Max: 6

# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 100
AllowURI: true

# Configuration parameters: CountComments.
Metrics/MethodLength:
Enabled: false

# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Enabled: false
Max: 5

Metrics/PerceivedComplexity:
Enabled: false
Max: 7

# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Enabled: false
EnforcedStyle: nested
SupportedStyles:
- nested
- compact

Style/Documentation:
Enabled: false

Style/DoubleNegation:
Enabled: false

# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Enabled: false
EnforcedStyle: format
SupportedStyles:
- format
- sprintf
- percent

# Offense count: 3
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
Style/PredicateName:
Enabled: false
NamePrefix:
- is_
- has_
- have_
NamePrefixBlacklist:
- is_
- has_
- have_


Style/TrailingCommaInLiteral:
Enabled: true
EnforcedStyleForMultiline: consistent_comma
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
language: ruby
sudo: false
cache: bundler
script: bundle exec rspec
script:
- bundle exec rspec
- bundle exec rubocop
rvm:
- 1.9.3
- 2.1.10
Expand Down
19 changes: 10 additions & 9 deletions bin/interferon
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ require 'yaml'
require 'optparse'
require 'interferon'

options={}
options = {}

# set command line options
optparse = OptionParser.new do |opts|
opts.banner = %{Usage: interferon --config /path/to/interferon/config}
opts.banner = %(Usage: interferon --config /path/to/interferon/config)

opts.on('-c config','--config config', String, 'Path to interferon config') do |key,value|
opts.on('-c config', '--config config', String, 'Path to interferon config') do |key, _value|
options[:config] = key
end

Expand All @@ -26,15 +26,15 @@ end

def parseconfig(filename)
begin
c = YAML::parse(File.read(filename))
c = YAML.parse(File.read(filename))
rescue Errno::ENOENT => e
raise ArgumentError, "config file does not exist:\n#{e.inspect}"
rescue Errno::EACCES => e
raise ArgumentError, "could not open config file:\n#{e.inspect}"
rescue YAML::SyntaxError => e
raise "config file #{filename} contains invalid YAML:\n#{e.inspect}"
end
return c.to_ruby
c.to_ruby
end

# parse command line arguments
Expand All @@ -46,8 +46,8 @@ end

# validate that required options are present
config = parseconfig(options[:config])
%w{alerts_repo_path host_sources destinations}.each do |req|
unless config.include?(req) && ! config[req].empty?
%w(alerts_repo_path host_sources destinations).each do |req|
unless config.include?(req) && !config[req].empty?
puts "config file has no #{req} defined; exiting"
exit 2
end
Expand All @@ -59,8 +59,9 @@ a = Interferon::Interferon.new(
config['alerts_repo_path'],
config['group_sources'] || {},
config['host_sources'],
config['destinations'])
config['destinations']
)

a.run(options[:dry_run])

puts "interferon signaling complete!"
puts 'interferon signaling complete!'
35 changes: 18 additions & 17 deletions interferon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'interferon/version'

Gem::Specification.new do |gem|
gem.name = "interferon"
gem.name = 'interferon'
gem.version = Interferon::VERSION
gem.authors = ["Igor Serebryany", "Jimmy Ngo"]
gem.email = ["igor.serebryany@airbnb.com", "jimmy.ngo@airbnb.com"]
gem.description = %q{: Store metrics alerts in code!}
gem.summary = %q{: Store metrics alerts in code!}
gem.homepage = "https://www.github.com/airbnb/interferon"
gem.authors = ['Igor Serebryany', 'Jimmy Ngo']
gem.email = ['igor.serebryany@airbnb.com', 'jimmy.ngo@airbnb.com']
gem.description = %(: Store metrics alerts in code!)
gem.summary = %(: Store metrics alerts in code!)
gem.homepage = 'https://www.github.com/airbnb/interferon'
gem.licenses = ['MIT']

gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})

gem.add_runtime_dependency "dogapi", "~> 1.11", ">= 1.11.1"
gem.add_runtime_dependency "aws-sdk", "~> 1.35", ">= 1.35.1"
gem.add_runtime_dependency "dogstatsd-ruby", "~> 1.4", ">= 1.4.1"
gem.add_runtime_dependency "diffy", "~> 3.1.0", ">= 3.1.0"
gem.add_runtime_dependency "parallel", "~> 1.9", ">= 1.9.0"
gem.add_runtime_dependency "nokogiri", "< 1.7.0"
gem.add_runtime_dependency "tzinfo", "~> 1.2.2", ">= 1.2.2"
gem.add_runtime_dependency 'dogapi', '~> 1.11', '>= 1.11.1'
gem.add_runtime_dependency 'aws-sdk', '~> 1.35', '>= 1.35.1'
gem.add_runtime_dependency 'dogstatsd-ruby', '~> 1.4', '>= 1.4.1'
gem.add_runtime_dependency 'diffy', '~> 3.1.0', '>= 3.1.0'
gem.add_runtime_dependency 'parallel', '~> 1.9', '>= 1.9.0'
gem.add_runtime_dependency 'nokogiri', '< 1.7.0'
gem.add_runtime_dependency 'tzinfo', '~> 1.2.2', '>= 1.2.2'

gem.add_development_dependency "rspec", "~> 3.2"
gem.add_development_dependency "pry", "~> 0.10"
gem.add_development_dependency 'rspec', '~> 3.2'
gem.add_development_dependency 'pry', '~> 0.10'
gem.add_development_dependency 'rubocop', '0.41.2'
end

0 comments on commit 91fcd73

Please sign in to comment.