Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rubocop #9

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test

on: [pull_request]

# permissions:
# contents: read

jobs:
lint:
runs-on: ubuntu-latest
# env:
# BUNDLE_ONLY: rubocop

steps:
- uses: actions/checkout@v4

- name: Set up Ruby 3.2.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true

- name: Run Tests
run: bundle exec rubocop --parallel
# run: bundle exec rake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/pkg/
/spec/reports/
/tmp/
Gemfile.lock
75 changes: 75 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# see example at https://gist.github.com/jhass/a5ae80d87f18e53e7b56

# <% unless ENV['BYPASS_RUBOCOP_TODO'] %>
# inherit_from:
# <% else %>
# inherit_from:
# - '.rubocop-todo.yml'
# <% end %>

inherit_from:
- .rubocop_todo.yml

require:
- rubocop-rake
- rubocop-performance

AllCops:
NewCops: enable
# TargetRubyVersion: 2.7.8
# TargetRailsVersion: 6.1.4
# Exclude:
# - 'Gemfile.lock'

Naming/VariableNumber:
Enabled: false

Layout/SpaceInsideHashLiteralBraces:
Enabled: false

Layout/EmptyLinesAroundModuleBody:
EnforcedStyle: empty_lines_special
Enabled: false

Layout/TrailingEmptyLines:
Enabled: false
EnforcedStyle: final_blank_line

Layout/EmptyLinesAroundClassBody:
Enabled: false

Style/RaiseArgs:
EnforcedStyle: compact

Naming/MethodParameterName:
Enabled: false

Naming/VariableName:
Enabled: false

Layout/FirstHashElementIndentation:
Enabled: false

Layout/CaseIndentation:
EnforcedStyle: end

Metrics/ParameterLists:
Enabled: false

Style/Lambda:
EnforcedStyle: literal

Layout/IndentationWidth:
Enabled: false

Layout/EndAlignment:
Enabled: false

Layout/ElseAlignment:
Enabled: false

Style/TrivialAccessors:
Enabled: false

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
55 changes: 55 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-03-18 18:37:56 UTC using RuboCop version 1.62.1.
# 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.

# Offense count: 9
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 60

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 35

# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 17

# Offense count: 14
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 42

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 153

# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 18

# Offense count: 6
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/elasticsearch_repositories/adapters/multistrategy.rb'
- 'lib/elasticsearch_repositories/model.rb'
- 'lib/elasticsearch_repositories/response/result.rb'
- 'lib/elasticsearch_repositories/search_request.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RescueModifier:
Exclude:
- 'lib/elasticsearch_repositories/strategy/searching.rb'
15 changes: 13 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
source "https://rubygems.org"
# frozen_string_literal: true

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in elasticsearch_model_repositories.gemspec
gemspec

# gem 'bundler', '2.4.22'
gem 'debug', '>= 1.0.0'
gem 'rake', '~> 13.1'

# rubocop
gem 'rubocop', '~> 1.62'
gem 'rubocop-performance', '~> 1.20'
gem 'rubocop-rake', '~> 0.6'
74 changes: 0 additions & 74 deletions Gemfile.lock

This file was deleted.

12 changes: 7 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require "bundler/gem_tasks"
require "rake/testtask"
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_spec.rb"]
t.libs << 'test'
t.test_files = FileList['test/**/*_spec.rb']
t.verbose = true
end

task :default => :test
task default: :test
7 changes: 4 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "elasticsearch_model_repositories"
require 'bundler/setup'
require 'elasticsearch_model_repositories'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand All @@ -10,5 +11,5 @@ require "elasticsearch_model_repositories"
# require "pry"
# Pry.start

require "irb"
require 'irb'
IRB.start(__FILE__)
56 changes: 22 additions & 34 deletions elasticsearch_model_repositories.gemspec
Original file line number Diff line number Diff line change
@@ -1,48 +1,36 @@
# frozen_string_literal: true

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "elasticsearch_repositories/version"
require_relative 'lib/elasticsearch_repositories/version'

Gem::Specification.new do |spec|
spec.name = "elasticsearch_model_repositories"
spec.name = 'elasticsearch_model_repositories'
spec.version = ElasticsearchRepositories::VERSION
spec.authors = ["Pato"]
spec.email = ["[email protected]"]
spec.authors = ['Pato']
spec.email = ['[email protected]']

spec.summary = %q{Repositories pattern for activerecord models.}
spec.description = %q{Support multiple repositories for each model.}
spec.summary = 'Repositories pattern for activerecord models.'
spec.description = 'Support multiple repositories for each model.'
# spec.homepage = "TODO: Put your gem's website or public repo URL here."
# spec.license = 'MIT'
spec.required_ruby_version = '>= 3.1.0'

# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
# if spec.respond_to?(:metadata)
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"

# spec.metadata["homepage_uri"] = spec.homepage
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
# else
# raise "RubyGems 2.0 or newer is required to protect against " \
# "public gem pushes."
# end
# spec.metadata["homepage_uri"] = spec.homepage
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
spec.metadata['rubygems_mfa_required'] = 'true'

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.files = Dir.chdir(__dir__) do
`git ls-files -z`.split("\x0").reject do |f|
(File.expand_path(f) == __FILE__) ||
f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
end
end
spec.bindir = "exe"
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "elasticsearch", '~> 8'
spec.add_dependency "activesupport", '~> 6'

# spec.add_development_dependency 'activemodel', '> 3'
spec.add_development_dependency "bundler", "2.4.22"
spec.add_development_dependency "rake", "~> 13.1"
spec.add_development_dependency "debug", ">= 1.0.0"
spec.add_development_dependency "minitest", "~> 5.14"
spec.add_development_dependency "minitest-reporters", "~> 1.6"
spec.require_paths = ['lib']

spec.add_dependency 'activesupport', '~> 6'
spec.add_dependency 'elasticsearch', '~> 8'
end
Loading