Skip to content

Commit

Permalink
[Ruby]: Update conformance (#133)
Browse files Browse the repository at this point in the history
* Re-order gemspec requirements. Add rubocop legacy version and update minimum ruby to 2.3

* Remove all redundant items and use let's in specs

* Add initial config

* Add placeholder changelog

* Add rubocop styling into repo config

* Add initial state for repo config

* Update release workflow to use latest ruby version

* Update runner to test later versions of ruby

* Verbosely set rubygems version to mitigate vs runner issues with rubygems versions

* Add changelog PR ref

* Easy spacing fixes
  • Loading branch information
luke-hill authored Oct 13, 2023
1 parent e9eb81b commit 4a1f26b
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-rubygem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.2'
ruby-version: '3.2'
bundler-cache: true
- uses: cucumber/[email protected]
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ jobs:
matrix:
os:
- ubuntu-latest
ruby: ['2.5', '2.6', '2.7', '3.0']
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
include:
- os: windows-latest
ruby: '3.0'
ruby: '3.2'
- os: macos-latest
ruby: '3.0'
ruby: '3.2'

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
rubygems: '3.0.8'
working-directory: ruby
- run: bundle exec rspec
working-directory: ruby
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- [Ruby] Initial rubocop gems and basic compliance added (More work to come) ([#133](https://github.com/cucumber/tag-expressions/pull/133))

### Changed
- [Ruby] Minimum ruby version is now bumped from 1.9 to 2.3 ([#133](https://github.com/cucumber/tag-expressions/pull/133))

### Fixed
- [Perl] Include README.md and LICENSE in the release tarball
(by [ehuelsmann](https://github.com/ehuelsmann))
Expand Down
5 changes: 0 additions & 5 deletions ruby/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
Gemfile.lock
coverage/
acceptance/
pkg/
*.gem
.compared
.deps
.tested*
*-go
*.iml
35 changes: 35 additions & 0 deletions ruby/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# TODO: Re-enable once tag-expressions > 7.0
#require:
# - rubocop-performance
# - rubocop-rake
# - rubocop-rspec

inherit_from: .rubocop_todo.yml

inherit_mode:
merge:
- Exclude

AllCops:
TargetRubyVersion: 2.3
# TODO: Re-enable once rubocop > 1.10
# NewCops: enable

# Disabled on our repo's to enable polyglot-release
# TODO: Re-enable once rubocop > 1.40
#Gemspec/RequireMFA:
# Enabled: false

Layout/LineLength:
Max: 200

Style/Documentation:
Enabled: false

Style/RegexpLiteral:
EnforcedStyle: slashes
AllowInnerSlashes: true

# TODO: Re-enable once rubocop-rspec > 1.20
#RSpec/MessageSpies:
# EnforcedStyle: receive
244 changes: 244 additions & 0 deletions ruby/.rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-10-06 16:28:14 +0100 using RuboCop version 0.79.0.
# 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.

# TODO: Oct '23 -> 9 files inspected, 78 offenses detected

# Offense count: 3
# Cop supports --auto-correct.
Layout/EmptyLineAfterGuardClause:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'Gemfile'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Exclude:
- 'cucumber-tag-expressions.gemspec'
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/FirstHashElementIndentation:
Exclude:
- 'cucumber-tag-expressions.gemspec'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'cucumber-tag-expressions.gemspec'
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleInsidePipes.
# SupportedStylesInsidePipes: space, no_space
Layout/SpaceAroundBlockParameters:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
# SupportedStylesForExponentOperator: space, no_space
Layout/SpaceAroundOperators:
Exclude:
- 'cucumber-tag-expressions.gemspec'
- 'lib/cucumber/tag_expressions/expressions.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/cucumber/tag_expressions/expressions.rb'

# Offense count: 2
Metrics/AbcSize:
Max: 27

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 132

# Offense count: 1
Metrics/CyclomaticComplexity:
Max: 13

# Offense count: 2
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 29

# Offense count: 1
Metrics/PerceivedComplexity:
Max: 15

# Offense count: 1
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db, os
Naming/MethodParameterName:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: percent_q, bare_percent
Style/BarePercentLiterals:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'
- 'spec/errors_spec.rb'
- 'spec/parsing_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 1
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/cucumber/tag_expressions/expressions.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/Encoding:
Exclude:
- 'cucumber-tag-expressions.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
Style/ExpandPathArguments:
Exclude:
- 'Rakefile'

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, never
Style/FrozenStringLiteralComment:
Exclude:
- 'Rakefile'
- 'cucumber-tag-expressions.gemspec'
- 'lib/cucumber/tag_expressions.rb'
- 'lib/cucumber/tag_expressions/expressions.rb'
- 'lib/cucumber/tag_expressions/parser.rb'
- 'spec/errors_spec.rb'
- 'spec/evaluations_spec.rb'
- 'spec/parsing_spec.rb'

# Offense count: 2
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: both, prefix, postfix
Style/NegatedIf:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'
- 'spec/errors_spec.rb'
- 'spec/parsing_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: .
# SupportedStyles: use_perl_names, use_english_names
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names

# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'Rakefile'
- 'cucumber-tag-expressions.gemspec'
- 'lib/cucumber/tag_expressions/expressions.rb'
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'cucumber-tag-expressions.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
Style/WhileUntilModifier:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/ZeroLengthPredicate:
Exclude:
- 'lib/cucumber/tag_expressions/parser.rb'

# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 140
2 changes: 2 additions & 0 deletions ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
5 changes: 0 additions & 5 deletions ruby/Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# encoding: utf-8
require 'rubygems'
require 'bundler'
Bundler::GemHelper.install_tasks

$:.unshift File.expand_path("../lib", __FILE__)

require "rspec/core/rake_task"
Expand Down
9 changes: 4 additions & 5 deletions ruby/cucumber-tag-expressions.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- encoding: utf-8 -*-

version = File.read(File.expand_path("VERSION", __dir__)).strip

Gem::Specification.new do |s|
Expand All @@ -12,7 +10,8 @@ Gem::Specification.new do |s|
s.homepage = 'https://cucumber.io/docs/cucumber/api/#tag-expressions'
s.platform = Gem::Platform::RUBY
s.license = 'MIT'
s.required_ruby_version = '>= 1.9.3'
s.required_ruby_version = '>= 2.3'
s.required_rubygems_version = '>= 3.0.8'

s.metadata = {
'bug_tracker_uri' => 'https://github.com/cucumber/cucumber/issues',
Expand All @@ -23,9 +22,9 @@ Gem::Specification.new do |s|
}

s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
s.add_development_dependency 'rspec', '~> 3.10', '>= 3.10.0'
s.add_development_dependency 'rspec', '~> 3.11'
s.add_development_dependency 'rubocop', '~> 0.79.0'

s.rubygems_version = '>= 1.6.1'
s.files = Dir[
'README.md',
'LICENSE',
Expand Down
Loading

0 comments on commit 4a1f26b

Please sign in to comment.