Skip to content

Commit

Permalink
Technical/Init Rails App (#4)
Browse files Browse the repository at this point in the history
* Init Rails App
Add and config linters
Add and config RSpec
Add and config Sidekiq
Config app initializers
Add macroses, services, default concepts
Add tests

* Add ModelDelete, ModelDestroy macroses

* Update readme

* Refactor

* Fix schema
  • Loading branch information
bestwebua authored and chubchenko committed Aug 6, 2019
1 parent de420da commit 8e1c799
Show file tree
Hide file tree
Showing 115 changed files with 3,758 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore secrets
/config/application.yml
/config/database.yml
/config/cable.yml
/config/master.key

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/pids/.keep
!/tmp/.keep
.rvmrc

.DS_Store
.byebug_history

# Ignore spec files
/spec/examples.txt

# Ignore test coverage info
/coverage/*

# Ignore RubyMine IDE configs
/.idea

/vendor/bundle
55 changes: 55 additions & 0 deletions .overcommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
PreCommit:
AuthorEmail:
enabled: true
required: false

AuthorName:
enabled: false

BundleAudit:
enabled: true

Brakeman:
enabled: true
flags: ['--exit-on-warn', '--quiet', '--summary']

Fasterer:
enabled: true
include: '**/*.rb'

TrailingWhitespace:
enabled: true
exclude:
- 'db/structure.sql'

RailsBestPractices:
enabled: true

RailsSchemaUpToDate:
enabled: true
include:
- 'db/migrate/*.rb'
- 'db/schema.rb'
- 'db/structure.sql'

Reek:
enabled: true
flags: ['--force-exclusion']

RuboCop:
enabled: true
flags: ['--format=emacs', '--force-exclusion', '--display-cop-names']
include:
- '**/*.gemspec'
- '**/*.rake'
- '**/*.rb'
- '**/*.ru'
- '**/Gemfile'
- '**/Rakefile'

PostCheckout:
ALL:
quiet: true # Change all post-checkout hooks to only display output on failure

IndexTags:
enabled: true # Generate a tags file with `ctags` each time HEAD changes
90 changes: 90 additions & 0 deletions .reek.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
detectors:
IrresponsibleModule:
enabled: false

UncommunicativeModuleName:
accept:
- BoilerplateRailsApi
- V1

NestedIterators:
max_allowed_nesting: 2
ignore_iterators:
- lambda

DataClump:
exclude:
- DefaultEndpoint

FeatureEnvy:
exclude:
- DefaultEndpoint#render_response

TooManyStatements:
exclude:
- DefaultEndpoint#default_handler
- Macro#self.ModelDecorator
- Macro#self.LinksBuilder
- Macro::Contract::BaseSchemaObject#self.Build
- Macro::Contract#self.Schema
- Macro#self.Model
- Macro#self.Assign

NilCheck:
exclude:
- Macro#self.Renderer
- Api::V1::Lib::Operation::Paginate#pagy

UtilityFunction:
exclude:
- test_matcher
- DefaultEndpoint#error_serializer_by_status
- Service::Jsonapi::ResourceErrorSerializer#compose_errors
- Service::Jsonapi::ResourceErrorSerializer#plain_errors?
- Service::Jsonapi::UriQueryErrorSerializer#compose_nested_errors
- Macro::Contract::BaseSchemaObject#build_schema

LongParameterList:
max_params: 6

ControlParameter:
exclude:
- Macro::Model#self.direction
- Service::Pagy#call
- Macro#self.Model
- Macro#self.Assign

BooleanParameter:
exclude:
- Macro#self.Model
- Macro#self.Assign

directories:
'app/concepts':
UtilityFunction:
enabled: false

DuplicateMethodCall:
allow_calls:
- 'ctx'

FeatureEnvy:
enabled: false

DataClump:
max_copies: 5

'lib/macro':
UncommunicativeMethodName:
enabled: false

DuplicateMethodCall:
allow_calls:
- 'ctx'

'spec/support/helpers':
UtilityFunction:
enabled: false

exclude_paths:
- db/
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require rails_helper
127 changes: 127 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
require:
- rubocop-rails
- rubocop-rspec
- rubocop-performance

AllCops:
Exclude:
- bin/**/*
- db/**/*
- vendor/**/*
- spec/fixtures/**/*
- tmp/**/*

Rails:
Enabled: true

# Style -----------------------------------------------------------------------

Style/Documentation:
Enabled: false

Style/ParallelAssignment:
Enabled: false

Style/ClassAndModuleChildren:
Exclude:
- app/concepts/**/*
- app/controllers/**/*

Style/Lambda:
Exclude:
- app/endpoints/**/*.rb
- lib/macro/**/*.rb

Style/SignalException:
Exclude:
- app/concepts/**/*.rb

# Metrics ---------------------------------------------------------------------

Metrics/LineLength:
Max: 120

Metrics/BlockLength:
Exclude:
- config/**/*.rb
- Rakefile
- lib/tasks/**/*.rake
- spec/**/*.rb
- config/routes.rb

Metrics/AbcSize:
Exclude:
- app/controllers/concerns/default_endpoint.rb
- lib/macro/model.rb

Metrics/MethodLength:
Max: 15
Exclude:
- lib/macro/**/*.rb

# Naming ----------------------------------------------------------------------

Naming/MethodName:
Exclude:
- lib/macro/**/*.rb

# Lint ------------------------------------------------------------------------

Lint/UnreachableCode:
Exclude:
- app/concepts/**/*.rb

# Layout ----------------------------------------------------------------------

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Layout/IndentFirstArrayElement:
EnforcedStyle: consistent

Layout/ClassStructure:
Enabled: true
Categories:
module_inclusion:
- include
- prepend
- extend
associations:
- has_one
- has_many
- belongs_to
- has_and_belongs_to_many
ExpectedOrder:
- module_inclusion
- constants
- associations
- public_class_methods
- initializer
- public_methods
- protected_methods
- private_methods

# RSpec -----------------------------------------------------------------------

RSpec/MultipleExpectations:
Enabled: false

RSpec/ExampleLength:
Max: 22

RSpec/MessageSpies:
EnforcedStyle: receive

RSpec/MessageChain:
Enabled: false

RSpec/NestedGroups:
Max: 5

RSpec/FilePath:
Exclude:
- spec/concepts/**/*.rb

RSpec/ContextWording:
Exclude:
- spec/support/shared_contexts/**/*.rb
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
boilerplate-rails-api
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.3
69 changes: 69 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: true

source 'https://rubygems.org'

ruby(File.read(File.join(File.dirname(__FILE__), '.ruby-version')).strip)

# System
gem 'pg', '~> 1.1', '>= 1.1.4'
gem 'puma', '~> 4.0', '>= 4.0.1'
gem 'rails', '6.0.0.rc2'
gem 'sidekiq', '~> 5.2', '>= 5.2.7'

# Trailblazer bundle
gem 'dry-validation', '0.11.1'
gem 'trailblazer', '2.1.0rc13'
gem 'trailblazer-endpoint', github: 'trailblazer/trailblazer-endpoint'

# Decorator
gem 'draper', '~> 3.1'

# JSON:API Serializer
gem 'fast_jsonapi', '~> 1.5'
gem 'oj', '~> 3.8', '>= 3.8.1'

# Pagination
gem 'pagy', '~> 3.4', '>= 3.4.1'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

# Authentication
gem 'jwt_sessions', '~> 2.4', '>= 2.4.2'

group :development, :test do
gem 'factory_bot_rails', '~> 5.0', '>= 5.0.2'
gem 'ffaker', '~> 2.11'
gem 'pry-byebug', '~> 3.7'
gem 'pry-rails', '~> 0.3.9'
gem 'rspec-rails', '~> 3.8', '>= 3.8.2'

# Code quality
gem 'brakeman', '~> 4.6', '>= 4.6.1', require: false
gem 'bundle-audit', '~> 0.1.0', require: false
gem 'fasterer', '~> 0.6.0', require: false
gem 'overcommit', '~> 0.49.0', require: false
gem 'rails_best_practices', '~> 1.19', '>= 1.19.4', require: false
gem 'reek', '5.3.2', require: false
gem 'rubocop', '~> 0.74.0', require: false
gem 'rubocop-performance', '~> 1.4', '>= 1.4.1', require: false
gem 'rubocop-rails', '~> 2.2', '>= 2.2.1', require: false
gem 'rubocop-rspec', '~> 1.35', require: false
end

group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring', '~> 2.1'
gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
gem 'dox', '~> 1.1'
gem 'json_matchers', '~> 0.11.1', require: 'json_matchers/rspec'
gem 'rails-controller-testing', '~> 1.0', '>= 1.0.4'
gem 'rspec-sidekiq', '~> 3.0', '>= 3.0.3'
gem 'shoulda-matchers', '~> 4.1', '>= 4.1.2'
gem 'simplecov', '~> 0.17.0', require: false
gem 'simplecov-lcov', '~> 0.7.0', require: false
gem 'undercover', '~> 0.3.2', require: false
end
Loading

0 comments on commit 8e1c799

Please sign in to comment.