Skip to content

Commit 3a953eb

Browse files
committed
add rubocop, github actions
1 parent c7a966f commit 3a953eb

14 files changed

+268
-146
lines changed

.github/workflows/test.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
3+
on: [pull_request]
4+
5+
# permissions:
6+
# contents: read
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
# env:
12+
# BUNDLE_ONLY: rubocop
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Ruby 3.2.2
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: 3.2.2
21+
bundler-cache: true
22+
23+
- name: Run Tests
24+
run: bundle exec rake
25+
# run: bundle exec rubocop --parallel

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9-
.byebug_history
9+
Gemfile.lock

.rubocop-minitest.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
###########################################################
2+
#################### Rubocop Minitest #####################
3+
###########################################################
4+
5+
Minitest/AssertTruthy:
6+
Enabled: false
7+
8+
Minitest/RefuteFalse:
9+
Enabled: false
10+
11+
Minitest/MultipleAssertions:
12+
Max: 4

.rubocop.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# see example at https://gist.github.com/jhass/a5ae80d87f18e53e7b56
2+
3+
# <% unless ENV['BYPASS_RUBOCOP_TODO'] %>
4+
# inherit_from:
5+
# <% else %>
6+
# inherit_from:
7+
# - '.rubocop-todo.yml'
8+
# <% end %>
9+
10+
inherit_from:
11+
- .rubocop_todo.yml
12+
- .rubocop-minitest.yml
13+
14+
require:
15+
- rubocop-minitest
16+
- rubocop-rake
17+
- rubocop-performance
18+
19+
AllCops:
20+
NewCops: enable
21+
# TargetRubyVersion: 2.7.8
22+
# TargetRailsVersion: 6.1.4
23+
# Exclude:
24+
# - 'Gemfile.lock'
25+
26+
Naming/VariableNumber:
27+
Enabled: false
28+
29+
Layout/SpaceInsideHashLiteralBraces:
30+
Enabled: false
31+
32+
Style/FrozenStringLiteralComment:
33+
Enabled: false
34+
35+
Layout/EmptyLinesAroundModuleBody:
36+
EnforcedStyle: empty_lines_special
37+
Enabled: false
38+
39+
Layout/TrailingEmptyLines:
40+
Enabled: false
41+
EnforcedStyle: final_blank_line
42+
43+
Layout/EmptyLinesAroundClassBody:
44+
Enabled: false
45+
46+
Style/RaiseArgs:
47+
EnforcedStyle: compact

.rubocop_todo.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2024-03-20 18:00:51 UTC using RuboCop version 1.62.1.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 6
10+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
11+
Metrics/AbcSize:
12+
Max: 46
13+
14+
# Offense count: 3
15+
# Configuration parameters: AllowedMethods, AllowedPatterns.
16+
Metrics/CyclomaticComplexity:
17+
Max: 11
18+
19+
# Offense count: 3
20+
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
21+
Metrics/MethodLength:
22+
Exclude:
23+
- 'test/spec/super_hash/utils_spec.rb'
24+
- 'lib/json_locale.rb'
25+
- 'test/spec/json_locale_test.rb'
26+
27+
# Offense count: 1
28+
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
29+
Metrics/ParameterLists:
30+
Max: 7
31+
32+
# Offense count: 3
33+
# Configuration parameters: AllowedMethods, AllowedPatterns.
34+
Metrics/PerceivedComplexity:
35+
Max: 11
36+
37+
# Offense count: 3
38+
# Configuration parameters: Max.
39+
Minitest/MultipleAssertions:
40+
Exclude:
41+
- 'test/spec/json_locale_test.rb'
42+
43+
# Offense count: 1
44+
# This cop supports safe autocorrection (--autocorrect).
45+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
46+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
47+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
48+
# FunctionalMethods: let, let!, subject, watch
49+
# AllowedMethods: lambda, proc, it
50+
Style/BlockDelimiters:
51+
Exclude:
52+
- 'test/spec/json_locale_test.rb'
53+
54+
# Offense count: 3
55+
# Configuration parameters: AllowedConstants.
56+
Style/Documentation:
57+
Exclude:
58+
- 'spec/**/*'
59+
- 'test/**/*'
60+
- 'lib/json_locale.rb'

Gemfile

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
source "https://rubygems.org"
1+
# frozen_string_literal: true
22

3-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3+
source 'https://rubygems.org'
4+
5+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
46

57
# Specify your gem's dependencies in json_locale.gemspec
68
gemspec
9+
10+
# gem 'bundler', '2.4.22'
11+
gem 'debug', '>= 1.0.0'
12+
gem 'minitest', '~> 5.14'
13+
gem 'minitest-reporters', '~> 1.6'
14+
gem 'rake', '~> 13.1'
15+
16+
# rubocop
17+
gem 'rubocop', '~> 1.62'
18+
gem 'rubocop-minitest', '~> 0.35'
19+
gem 'rubocop-performance', '~> 1.20'
20+
gem 'rubocop-rake', '~> 0.6'

Gemfile.lock

-46
This file was deleted.

Rakefile

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
require "bundler/gem_tasks"
2-
require "rake/testtask"
1+
# frozen_string_literal: true
2+
3+
require 'bundler/gem_tasks'
4+
require 'rake/testtask'
35

46
Rake::TestTask.new do |t|
5-
t.libs << "test"
6-
t.test_files = FileList["test/**/*_spec.rb"]
77
t.verbose = true
8+
t.warning = true
9+
t.libs << 'test'
10+
t.libs << 'lib'
11+
t.test_files = FileList['test/**/*_test.rb']
812
end
913

10-
task :default => :test
14+
require 'rubocop/rake_task'
15+
RuboCop::RakeTask.new
16+
17+
task default: %i[test rubocop]

bin/console

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

3-
require "bundler/setup"
4-
require "json_locale"
4+
require 'bundler/setup'
5+
require 'json_locale'
56

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

13-
require "irb"
14+
require 'irb'
1415
IRB.start(__FILE__)

json_locale.gemspec

+21-32
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
1+
# frozen_string_literal: true
12

2-
lib = File.expand_path("../lib", __FILE__)
3-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4-
require "json_locale/version"
3+
require_relative 'lib/json_locale/version'
54

65
Gem::Specification.new do |spec|
7-
spec.name = "json_locale"
6+
spec.name = 'json_locale'
87
spec.version = JsonLocale::VERSION
9-
spec.authors = ["Pato"]
10-
spec.email = ["pato_devilla@hotmail.com"]
8+
spec.authors = ['Pato']
9+
spec.email = ['pato_devilla@hotmail.com']
1110

12-
spec.summary = %q{Save translated data on jsons}
13-
spec.description = %q{Save translated data on jsons}
11+
spec.summary = 'Save translated data on jsons'
12+
spec.description = 'Save translated data on jsons'
1413
# spec.homepage = "TODO: Put your gem's website or public repo URL here."
14+
spec.license = 'MIT'
15+
spec.required_ruby_version = '>= 3.1.0'
1516

16-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17-
# to allow pushing to a single host or delete this section to allow pushing to any host.
18-
# if spec.respond_to?(:metadata)
19-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20-
21-
# spec.metadata["homepage_uri"] = spec.homepage
22-
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
23-
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24-
# else
25-
# raise "RubyGems 2.0 or newer is required to protect against " \
26-
# "public gem pushes."
27-
# end
17+
# spec.metadata["homepage_uri"] = spec.homepage
18+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
19+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20+
spec.metadata['rubygems_mfa_required'] = 'true'
2821

2922
# Specify which files should be added to the gem when it is released.
3023
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24+
spec.files = Dir.chdir(__dir__) do
25+
`git ls-files -z`.split("\x0").reject do |f|
26+
(File.expand_path(f) == __FILE__) ||
27+
f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
28+
end
3329
end
34-
spec.bindir = "exe"
35-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36-
spec.require_paths = ["lib"]
37-
38-
spec.add_development_dependency "bundler", "2.4.22"
39-
spec.add_development_dependency "rake", "~> 13.1"
40-
spec.add_development_dependency "debug", ">= 1.0.0"
41-
spec.add_development_dependency "minitest", "~> 5.14"
42-
spec.add_development_dependency "minitest-reporters", "~> 1.6"
43-
30+
spec.bindir = 'exe'
31+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32+
spec.require_paths = ['lib']
4433
end

0 commit comments

Comments
 (0)