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

Switching to standard gem for Ruby styling #246

Merged
merged 5 commits into from
Nov 26, 2022
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
11 changes: 3 additions & 8 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ plugins:
enabled: true
config:
languages:
- ruby
- ruby

fixme:
enabled: true

rubocop:
enabled: true
# Check https://github.com/codeclimate/codeclimate-rubocop/branches/all?query=channel%2Frubocop
channel: rubocop-1-31-0

exclude_patterns:
- spec/**/*
- certs/**/*
- spec/**/*
- certs/**/*
13 changes: 13 additions & 0 deletions .github/workflows/standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: StandardRB

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: StandardRB Linter
uses: andrewmcodes/standardrb-action@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176 changes: 5 additions & 171 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
require:
- standard
- rubocop-rails
- rubocop-rake
- rubocop-rspec

inherit_gem:
standard: config/base.yml

AllCops:
# Enable all the rules by default
EnabledByDefault: true
Expand All @@ -11,92 +16,8 @@ AllCops:
DisplayCopNames: true
SuggestExtensions: false
# Target versions
# We do not specify Ruby version, because CodeClimate should by default
# read .ruby-version, and send it down to Rubocop
# (see https://github.com/codeclimate/codeclimate-rubocop/pull/68)
TargetRubyVersion: 2.6
# We will lock Rails version to the newest we have in the company, so we're
# always looking to the future.
TargetRailsVersion: 5.1
# Exclude auto-generated and vendored files
Exclude:
- "db/schema.rb"

#-------------------------------------------------------------------------------
# Rules configuration
#-------------------------------------------------------------------------------

Bundler/OrderedGems:
TreatCommentsAsGroupSeparators: true

Layout/HashAlignment:
EnforcedColonStyle: table
EnforcedHashRocketStyle: table
EnforcedLastArgumentHashStyle: always_inspect

Layout/DotPosition:
EnforcedStyle: trailing

Layout/LineLength:
Max: 120
Exclude:
- "spec/**/*"

Layout/MultilineAssignmentLayout:
EnforcedStyle: same_line

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented_relative_to_receiver

# Requere spaces inside of brackets, e.g. [ 1, 2, 3 ]
Layout/SpaceInsideArrayLiteralBrackets:
Enabled: false
EnforcedStyle: compact

Metrics/AbcSize:
Max: 25

Metrics/BlockLength:
Exclude:
- "**/*.rake"
- "spec/**/*_spec.rb"
- "spec/spec_helper.rb"
- "meta-tags.gemspec"

Metrics/ClassLength:
Max: 250
CountComments: false

Metrics/MethodLength:
Max: 30

Metrics/ModuleLength:
Max: 250
CountComments: false

Rails/SafeNavigation:
ConvertTry: true

Style/Alias:
EnforcedStyle: prefer_alias_method

Style/ClassCheck:
EnforcedStyle: kind_of?

Style/Lambda:
EnforcedStyle: literal

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma

Style/BlockDelimiters:
EnforcedStyle: braces_for_chaining

#-------------------------------------------------------------------------------
# RSpec rules
Expand Down Expand Up @@ -130,97 +51,10 @@ RSpec/VerifiedDoubles:
# Disabled rules
#-------------------------------------------------------------------------------

# Yes, we have meta-tags.rb for simplicity
Naming/FileName:
Enabled: false

# Allow not null columns without a default value
Rails/NotNullColumn:
Enabled: false

# Do not require loading Rails enviroment for Rake tasks as we are not a Rails application.
Rails/RakeEnvironment:
Enabled: false

# Do not require subclassing from ApplicationController as we're not a rails application
Rails/ApplicationController:
Enabled: false

# This check does not distinguish between "private :x" and "private def x"
Style/AccessModifierDeclarations:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

# Do not require copyright information
Style/Copyright:
Enabled: false

# Do not require class and module documentation
Style/Documentation:
Enabled: false

# Do not require method documentation
Style/DocumentationMethod:
Enabled: false

# Allow double negation (!!@var)
Style/DoubleNegation:
Enabled: false

# Do not enforce if modifier, sometimes it is better to split for long lines
Style/IfUnlessModifier:
Enabled: false

# Allow trailing comments
Style/InlineComment:
Enabled: false

# Do not require parentheses around method arguments
Style/MethodCallWithArgsParentheses:
Enabled: false

# Do not enforce `else` on conditions
Style/MissingElse:
Enabled: false

# Allow both `.positive?` and `> 0` variants
Style/NumericPredicate:
Enabled: false

# Do not enforce using symbols for hash keys
Style/StringHashKeys:
Enabled: false

# Do not enforce usage of single quotes on strings
Style/StringLiterals:
Enabled: false

# Do not require to use %i[] around symbol arrays
Style/SymbolArray:
Enabled: false

# Do not require to use %w[] around word arrays
Style/WordArray:
Enabled: false

# Do not prohibit explicit Rubocop enable/disable directives
Style/DisableCopsWithinSourceCodeDirective:
Enabled: false

# Do not require keyword arguments when defining method with boolean argument (historical API)
Style/OptionalBooleanParameter:
Enabled: false

# Do not require fully qualified constants
Lint/ConstantResolution:
Enabled: false

# Bundler is only used for gem development
Bundler/GemVersion:
Enabled: false

# Developers can decide where to put their line breaks, thank you very much
Layout/RedundantLineBreak:
Enabled: false
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.19.0 (Development)

Changes:

- Switched code style from custom rules to Standard ([246](https://github.com/kpumuk/meta-tags/pull/246)).

## 2.18.0 (September 15, 2022) [☰](https://github.com/kpumuk/meta-tags/compare/v2.17.0...v2.18.0)

Changes:
Expand All @@ -10,7 +16,7 @@ Changes:

Changes:

- Separate RBS files to _internal directory to avoid exposing RBS ([237](https://github.com/kpumuk/meta-tags/pull/237))
- Separate RBS files to \_internal directory to avoid exposing RBS ([237](https://github.com/kpumuk/meta-tags/pull/237))
- Added Ruby 3.1 to supported versions, Ruby 2.6 is minimum supported version ([235](https://github.com/kpumuk/meta-tags/pull/235/))

## 2.16.0 (September 24, 2021) [☰](https://github.com/kpumuk/meta-tags/compare/v2.15.0...v2.16.0)
Expand Down
25 changes: 13 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in meta-tags.gemspec
gemspec

if ENV['RAILS_VERSION']
if ENV["RAILS_VERSION"]
# Install specified version of actionpack if requested
gem 'railties', "~> #{ENV['RAILS_VERSION']}"
gem "railties", "~> #{ENV["RAILS_VERSION"]}"
end

unless ENV["NO_STEEP"] == '1'
unless ENV["NO_STEEP"] == "1"
# Ruby typings
gem 'steep', '~> 1.1.1', platform: :mri
gem "steep", "~> 1.1.1", platform: :mri
end

group :test do
# Lock rubocop to a specific version we use on CI. If you update this,
# don't forget to switch rubocop channel in the .codeclimate.yml
gem 'rubocop', '= 1.31.0'
# Ruby Style Guide, with linter & automatic code fixer
gem "standard"
# Cops for rails apps
gem 'rubocop-rails'
gem "rubocop-rails"
# Cops for rake tasks
gem "rubocop-rake"
# Apply RSpec rubocop cops
gem 'rubocop-rspec', require: false
gem "rubocop-rspec", require: false
# We use this gem on CI to calculate code coverage.
gem 'simplecov', '~> 0.21.2'
gem "simplecov", "~> 0.21.2"
# Format RSpec output for CircleCI
gem 'rspec_junit_formatter'
gem "rspec_junit_formatter"
end
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![CircleCI](https://circleci.com/gh/kpumuk/meta-tags.svg?style=shield)](https://circleci.com/gh/kpumuk/meta-tags)
[![Gem Version](https://badge.fury.io/rb/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
[![Code Climate](https://codeclimate.com/github/kpumuk/meta-tags/badges/gpa.svg)](https://codeclimate.com/github/kpumuk/meta-tags)
[![Test Coverage](https://codeclimate.com/github/kpumuk/meta-tags/badges/coverage.svg)](https://codeclimate.com/github/kpumuk/meta-tags/coverage)
[![Gem Downloads](https://img.shields.io/gem/dt/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)
Expand Down
31 changes: 19 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# frozen_string_literal: true

require 'bundler'
require "bundler"
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

desc "Run RSpec tests"
task test: :spec
task default: :spec

desc 'Rebuild Circle CI configuration based on the build matrix template .circleci/config.yml.erb'
desc "Rebuild Circle CI configuration based on the build matrix template .circleci/config.yml.erb"
task :circleci do
require 'erb'
template_path = File.expand_path('.circleci/config.yml.erb', __dir__)
config_path = File.expand_path('.circleci/config.yml', __dir__)
require "erb"
template_path = File.expand_path(".circleci/config.yml.erb", __dir__)
config_path = File.expand_path(".circleci/config.yml", __dir__)
File.write config_path, ERB.new(File.read(template_path)).result
end

Expand All @@ -26,24 +27,30 @@ module SteepRunner
end
end

task :steep do
SteepRunner.run("check")
end
desc "Check type information"
task steep: "steep:check"

namespace :steep do
desc "Check type information"
task :check do
SteepRunner.run("check")
end

desc "Print type statistics"
task :stats do
SteepRunner.run("stats", "--log-level=fatal")
end
end

namespace :rbs do
desc "Run RSpec tests with RBS enabled to test type signatures"
task :spec do
exec(
{
'RBS_TEST_TARGET' => 'MetaTags::*',
'RUBYOPT' => '-rrbs/test/setup',
"RBS_TEST_TARGET" => "MetaTags::*",
"RUBYOPT" => "-rrbs/test/setup"
},
'bundle exec rspec',
"bundle exec rspec"
)
end
end
2 changes: 1 addition & 1 deletion lib/generators/meta_tags/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module MetaTags
module Generators
class InstallGenerator < Rails::Generators::Base
desc "Copy MetaTags default files"
source_root File.expand_path('templates', __dir__)
source_root File.expand_path("templates", __dir__)

def copy_config
template "config/initializers/meta_tags.rb"
Expand Down
2 changes: 1 addition & 1 deletion lib/meta-tags.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

require 'meta_tags'
require "meta_tags"
Loading