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, github actions #2

Merged
merged 1 commit into from
Mar 20, 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 rake
# run: bundle exec rubocop --parallel
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
/pkg/
/spec/reports/
/tmp/
.byebug_history
Gemfile.lock
12 changes: 12 additions & 0 deletions .rubocop-minitest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
###########################################################
#################### Rubocop Minitest #####################
###########################################################

Minitest/AssertTruthy:
Enabled: false

Minitest/RefuteFalse:
Enabled: false

Minitest/MultipleAssertions:
Max: 4
47 changes: 47 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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
- .rubocop-minitest.yml

require:
- rubocop-minitest
- 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

Style/FrozenStringLiteralComment:
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
60 changes: 60 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-03-20 18:00:51 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: 6
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 46

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 11

# Offense count: 3
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Exclude:
- 'test/spec/super_hash/utils_spec.rb'
- 'lib/json_locale.rb'
- 'test/spec/json_locale_test.rb'

# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 7

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 11

# Offense count: 3
# Configuration parameters: Max.
Minitest/MultipleAssertions:
Exclude:
- 'test/spec/json_locale_test.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
# FunctionalMethods: let, let!, subject, watch
# AllowedMethods: lambda, proc, it
Style/BlockDelimiters:
Exclude:
- 'test/spec/json_locale_test.rb'

# Offense count: 3
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/json_locale.rb'
18 changes: 16 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
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 json_locale.gemspec
gemspec

# gem 'bundler', '2.4.22'
gem 'debug', '>= 1.0.0'
gem 'minitest', '~> 5.14'
gem 'minitest-reporters', '~> 1.6'
gem 'rake', '~> 13.1'

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

This file was deleted.

17 changes: 12 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
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.verbose = true
t.warning = true
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end

task :default => :test
require 'rubocop/rake_task'
RuboCop::RakeTask.new

task default: %i[test rubocop]
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 "json_locale"
require 'bundler/setup'
require 'json_locale'

# 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 "json_locale"
# require "pry"
# Pry.start

require "irb"
require 'irb'
IRB.start(__FILE__)
53 changes: 21 additions & 32 deletions json_locale.gemspec
Original file line number Diff line number Diff line change
@@ -1,44 +1,33 @@
# frozen_string_literal: true

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

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

spec.summary = %q{Save translated data on jsons}
spec.description = %q{Save translated data on jsons}
spec.summary = 'Save translated data on jsons'
spec.description = 'Save translated data on jsons'
# 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.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

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.bindir = 'exe'
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
end
Loading