Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request codeforamerica#12 from appropriate/update-from-cfa…
Browse files Browse the repository at this point in the history
…-20170308

Update from CfA upstream
  • Loading branch information
md5 authored Mar 10, 2017
2 parents 65c8990 + 9fe6416 commit 06444de
Show file tree
Hide file tree
Showing 113 changed files with 1,106 additions and 696 deletions.
2 changes: 2 additions & 0 deletions .bummr-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
bundle exec rspec --fail-fast
36 changes: 36 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
engines:
brakeman:
enabled: true
bundler-audit:
enabled: true
csslint:
enabled: true
duplication:
enabled: true
config:
languages:
- ruby
# mass_threshold: 30
- javascript
exclude_paths:
- 'spec/**/*'
- 'db/migrate/*'
- 'db/schema.rb'
eslint:
enabled: true
fixme:
enabled: true
reek:
enabled: true
exclude_paths:
- 'db/migrate/*'
rubocop:
enabled: true
scss-lint:
enabled: true

ratings:
paths:
- app/**
- lib/**
- '**.rb'
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile
tmp
log
*.md
.git*
13 changes: 13 additions & 0 deletions .reek
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
IrresponsibleModule:
enabled: false
'spec':
DataClump:
enabled: false
LongParameterList:
enabled: false
TooManyStatements:
enabled: false
UtilityFunction:
enabled: false
exclude_paths:
- db/migrate
204 changes: 176 additions & 28 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,96 @@
# This configuration only includes the cops that differ from the Rubocop
# defaults, which can be found here:
# https://github.com/bbatsov/rubocop/blob/master/config/default.yml
# https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
# https://github.com/bbatsov/rubocop/blob/master/config/disabled.yml

AllCops:
Include:
- 'Gemfile'
- 'Rakefile'
- '**/Gemfile'
- '**/Rakefile'
- 'lib/tasks/*'
Exclude:
- 'bin/**/*'
- 'db/schema.rb'
- 'db/seeds.rb'
- 'bin/**/*'
- 'config/initializers/devise.rb'
- 'db/migrate/*'
- 'config/initializers/generators.rb'
TargetRubyVersion: 2.3
UseCache: true

Metrics/AbcSize:
Description: A calculated magnitude based on number of assignments, branches, and
conditions.
Enabled: true
Max: 15
Exclude:
- spec/**/*

Metrics/BlockLength:
CountComments: false # count full line comments?
Enabled: true
Max: 25
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'config/environments/production.rb'
- 'config/environments/test.rb'
- 'config/routes.rb'
- 'lib/location_presenter.rb'
- 'lib/location_importer.rb'
- 'spec/**/*.rb'

Metrics/ClassLength:
Description: Avoid classes longer than 100 lines of code.
Enabled: true
CountComments: false
Max: 100
Exclude:
- spec/**/*

Metrics/LineLength:
Description: Limit lines to 80 characters.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
Enabled: false
Enabled: true
Max: 100
AllowURI: true
URISchemes:
- http
- https
Exclude:
- config/initializers/secret_token.rb
- app/validators/url_validator.rb

Metrics/MethodLength:
Description: Avoid methods longer than 10 lines of code.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
Enabled: true
CountComments: false
Max: 15
Max: 10
Exclude:
- 'db/migrate/*'
- app/controllers/api/v1/root_controller.rb
- spec/**/*

Metrics/ModuleLength:
Description: Avoid modules longer than 100 lines of code.
Enabled: true
CountComments: false
Max: 100
Description: Avoid modules longer than 100 lines of code.
Enabled: true
Exclude:
- spec/support/features/form_helpers.rb
- spec/**/*

Rails/HasAndBelongsToMany:
Description: Prefer has_many :through to has_and_belongs_to_many.
Enabled: true
Exclude:
- app/models/service.rb
- app/models/category.rb
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
Enabled: false

Rails/ScopeArgs:
Description: Checks the arguments of ActiveRecord scopes.
Enabled: true
Exclude:
- app/models/concerns/search.rb
# This is a Rails 5 feature, so it should be disabled until we upgrade
Rails/HttpPositionalArguments:
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
Enabled: false
Include:
- app/models/**/*.rb
- 'spec/**/*'
- 'test/**/*'

Rails/TimeZone:
# The value `strict` means that `Time` should be used with `zone`.
Expand All @@ -65,10 +101,35 @@ Rails/TimeZone:
- strict
- flexible

Style/AlignParameters:
# Alignment of parameters in multi-line method calls.
#
# The `with_first_parameter` style aligns the following lines along the same
# column as the first parameter.
#
# method_call(a,
# b)
#
# The `with_fixed_indentation` style aligns the following lines with one
# level of indentation relative to the start of the line with the method call.
#
# method_call(a,
# b)
Description: >-
Align the parameters of a method call if they span more
than one line.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
EnforcedStyle: with_first_parameter
SupportedStyles:
- with_first_parameter
- with_fixed_indentation
# By default, the indentation width from Style/IndentationWidth is used
# But it can be overridden by setting this parameter
IndentationWidth: ~

Style/AndOr:
Description: Use &&/|| instead of and/or.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
Enabled: true
EnforcedStyle: conditionals
SupportedStyles:
- always
Expand All @@ -77,31 +138,118 @@ Style/AndOr:
Style/Documentation:
Description: Document classes and non-namespace modules.
Enabled: false
Exclude:
- 'spec/**/*'
- 'test/**/*'

Style/DotPosition:
Description: Checks the position of the dot in multi-line method calls.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
Enabled: true
EnforcedStyle: trailing
SupportedStyles:
- leading
- trailing

# Warn on empty else statements
# empty - warn only on empty else
# nil - warn on else with nil in it
# both - warn on empty else and else with nil in it
Style/EmptyElse:
EnforcedStyle: both
SupportedStyles:
- empty
- nil
- both

Style/ExtraSpacing:
Description: Do not use unnecessary spacing.
# When true, allows most uses of extra spacing if the intent is to align
# things with the previous or next line, not counting empty lines or comment
# lines.
AllowForAlignment: true
# When true, forces the alignment of = in assignments on consecutive lines.
ForceEqualSignAlignment: false

Style/FrozenStringLiteralComment:
Description: >-
Add the frozen_string_literal comment to the top of files
to help transition from Ruby 2.3.0 to Ruby 3.0.
Enabled: false

# `MinBodyLength` defines the number of lines of the a body of an if / unless
# needs to have to trigger this cop
Style/GuardClause:
Description: Check for conditionals that can be replaced with guard clauses
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
MinBodyLength: 2

Style/IfUnlessModifier:
Description: Favor modifier if/unless usage when you have a single-line body.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
Enabled: true
MinBodyLength: 3
MaxLineLength: 80

# Checks the indentation of the first element in an array literal.
Style/IndentArray:
# The value `special_inside_parentheses` means that array literals with
# brackets that have their opening bracket on the same line as a surrounding
# opening round parenthesis, shall have their first element indented relative
# to the first position inside the parenthesis.
#
# The value `consistent` means that the indentation of the first element shall
# always be relative to the first position of the line where the opening
# bracket is.
#
# The value `align_brackets` means that the indentation of the first element
# shall always be relative to the position of the opening bracket.
EnforcedStyle: special_inside_parentheses
SupportedStyles:
- special_inside_parentheses
- consistent
- align_brackets
# By default, the indentation width from Style/IndentationWidth is used
# But it can be overridden by setting this parameter
IndentationWidth: ~

Style/MultilineOperationIndentation:
EnforcedStyle: aligned
SupportedStyles:
- aligned
- indented
# By default, the indentation width from Style/IndentationWidth is used
# But it can be overridden by setting this parameter
IndentationWidth: ~

Style/NumericLiteralPrefix:
EnforcedOctalStyle: zero_only
SupportedOctalStyles:
- zero_with_o
- zero_only

Style/StringLiterals:
Description: Checks if uses of quotes match the configured preference.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
Enabled: true
EnforcedStyle: single_quotes
SupportedStyles:
- single_quotes
- double_quotes
ConsistentQuotesInMultiline: true

Style/TrailingCommaInArguments:
# If `comma`, the cop requires a comma after the last argument, but only for
# parenthesized method calls where each argument is on its own line.
# If `consistent_comma`, the cop requires a comma after the last argument,
# for all parenthesized method calls with arguments.
EnforcedStyleForMultiline: no_comma
SupportedStyles:
- comma
- consistent_comma
- no_comma

Style/TrailingCommaInLiteral:
# If `comma`, the cop requires a comma after the last item in an array or
# hash, but only when each item is on its own line.
# If `consistent_comma`, the cop requires a comma after the last item of all
# non-empty array and hash literals.
EnforcedStyleForMultiline: no_comma
SupportedStyles:
- comma
- consistent_comma
- no_comma
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.3
2.3.3
8 changes: 8 additions & 0 deletions .scss-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
linters:
Comment:
exclude:
- 'app/assets/stylesheets/application.css.scss'
- 'app/assets/stylesheets/admin/application.css.scss'
PlaceholderInExtend:
exclude:
- 'app/assets/stylesheets/framework_and_overrides.css.scss'
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ bundler_args: --without assets:development:production
language: ruby
cache: bundler
rvm:
- 2.2.3
- 2.3.3
addons:
postgresql: "9.3"
before_install:
- gem update --system
before_script:
- psql -c 'create database ohana_api_test;' -U postgres
- psql -U postgres -q -d ohana_api_test -f db/structure.sql
Expand Down
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use the rails image because it properly sets up Node.js and Postgres
FROM rails:4.2.6

# PhantomJS is required for running tests
ENV PHANTOMJS_SHA256 86dd9a4bf4aee45f1a84c9f61cf1947c1d6dce9b9e8d2a907105da7852460d2f

RUN mkdir /usr/local/phantomjs \
&& curl -o phantomjs.tar.bz2 -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 \
&& echo "$PHANTOMJS_SHA256 *phantomjs.tar.bz2" | sha256sum -c - \
&& tar -xjf phantomjs.tar.bz2 -C /usr/local/phantomjs --strip-components=1 \
&& rm phantomjs.tar.bz2

RUN ln -s ../phantomjs/bin/phantomjs /usr/local/bin/

WORKDIR /ohana-api

COPY Gemfile /ohana-api
COPY Gemfile.lock /ohana-api

RUN bundle install --jobs 20 --retry 5

COPY . /ohana-api

EXPOSE 8080
CMD ["rails", "server", "-b", "0.0.0.0", "-p", "8080"]
Loading

0 comments on commit 06444de

Please sign in to comment.