diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000000..8a002f79f32 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,13 @@ +inherit_gem: + stripe-rubocop: .rubocop.yml + +AllCops: + Exclude: + # Someday we should enable some formatting cops for these + - test/testdata/**/* + - test/cli/**/* + + # Things we didn't write + - bazel-*/**/* + - third_party/**/* + - parser/tools/generate_diagnostics.rb diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000000..6b4950e3de2 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.4 diff --git a/Dockerfile b/Dockerfile index b007efbfe26..8b2b25415b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,8 @@ RUN apt-get update && apt-get install -y ragel bison ruby autoconf # Dependencies for pay-server gems RUN apt-get update && apt-get install -y libpq-dev libicu-dev libsqlite3-dev +RUN rbenv exec gem install bundler --no-rdoc --no-ri + RUN /usr/stripe/bin/docker/stripe-install-go 1.9 d70eadefce8e160638a9a6db97f7192d8463069ab33138893ad3bf31b0650a79 ENV GOPATH /gopath ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000000..72303307d07 --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +# rubocop:disable PrisonGuard/NoRequireSideEffects + +found = ['~/.', '/etc/'].any? do |file| + begin + path = File.expand_path(file + 'bundle-gemfile-hook') + File.lstat(path) + rescue + next + end + instance_eval(File.read(path), path) + break true +end +source('https://rubygems.org/') if !found + +gem 'stripe-rubocop', '0.7.4' + +# rubocop:enable PrisonGuard/NoRequireSideEffects diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000000..2950a38e6d8 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,29 @@ +GEM + remote: https://intgems.local.corp.stripe.com:446/ + specs: + ast (2.4.0) + parallel (1.12.1) + parser (2.4.0.2) + ast (~> 2.3) + powerpack (0.1.1) + rainbow (3.0.0) + rubocop (0.52.1) + parallel (~> 1.10) + parser (>= 2.4.0.2, < 3.0) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.9.0) + stripe-rubocop (0.7.4) + rubocop (= 0.52.1) + unicode-display_width (1.3.0) + +PLATFORMS + ruby + +DEPENDENCIES + stripe-rubocop (= 0.7.4) + +BUNDLED WITH + 1.16.1 diff --git a/ci/stripe-internal-ruby-typer.sh b/ci/stripe-internal-ruby-typer.sh index 956c4bc5f8b..0f879826da1 100755 --- a/ci/stripe-internal-ruby-typer.sh +++ b/ci/stripe-internal-ruby-typer.sh @@ -6,6 +6,8 @@ set -eux ./tools/scripts/lint_sh.sh -t ./tools/scripts/generate_compdb_targets.sh -t ./tools/scripts/build_compilation_db.sh +rbenv exec bundle install +rbenv exec bundle exec rubocop err=0 diff --git a/test/import_whitequark.rb b/test/import_whitequark.rb index f88778e6450..3fd4376e9f6 100644 --- a/test/import_whitequark.rb +++ b/test/import_whitequark.rb @@ -24,4 +24,7 @@ def main cur_file = nil end end -main + +if $0 == __FILE__ + main +end diff --git a/test/t.rb b/test/t.rb index 59b1e8c0126..b3d10260ac4 100644 --- a/test/t.rb +++ b/test/t.rb @@ -1,21 +1,21 @@ +# rubocop:disable PrisonGuard/NoTopLevelDeclarations class T - def self.type(fixed: nil) - end - def self.assert_type!(*args) - end - def self.untyped - end + def self.type(fixed: nil); end + def self.assert_type!(*args); end + def self.untyped; end end + class T::Sig - def returns(*args) - end + def returns(*args); end end -def sig(*args) + +def sig(*_args) T::Sig.new end class Module - def [](*args) + def [](*_args) self end end +# rubocop:enable PrisonGuard/NoTopLevelDeclarations