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

Fixes and updates to bring up to ruby 3, contenful-migrations 3.0 etc. #3

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cd8d63a
Remove load rake task
patch0 Nov 10, 2021
f53fd00
Replace rake loading with railtie
patch0 Nov 10, 2021
6e36bcd
Use rails env
patch0 Nov 10, 2021
b9cd6a1
Fix path for generator
patch0 Nov 10, 2021
e1adab6
In Ruby 3, named params need to be splatted
patch0 Nov 10, 2021
1436e83
Upgrade contentful-management gem to v3
patch0 Nov 10, 2021
c7bf4c1
Mega refactor
patch0 Nov 10, 2021
3b7aff3
Version bump to v0.2.0
patch0 Nov 10, 2021
a91cefc
Add circle ci
patch0 Nov 10, 2021
589a40c
Fix version
patch0 Nov 10, 2021
31c34f9
Add junit formatter for circleci
patch0 Nov 10, 2021
22193de
Add a standard rubocop config
patch0 Nov 10, 2021
06be75b
Tidy rubocop config a little
patch0 Nov 10, 2021
826e1b3
Add rubocop todo file
patch0 Nov 10, 2021
5fe97c0
Raise errors by default in the Contentful::Management::Client
patch0 Nov 11, 2021
178769c
Move env vars back; ensure they're there and use ClimateControl in tests
patch0 Nov 11, 2021
9a2dc5c
Refactor MigrationContentType so that errors raised by contentful are…
patch0 Nov 12, 2021
dfdeba9
Refactor tests for ContentfulMigrations::Migrator
patch0 Nov 12, 2021
1db76a6
Use environment where we mean it; move default content type name
patch0 Nov 12, 2021
42fd001
Set the default locale on the client for the migration content type
patch0 Mar 8, 2022
22918e0
Poke the config directly
patch0 Mar 8, 2022
4e06044
Try setting the default locale on the environment instead
patch0 Mar 8, 2022
891d4b0
Use the locale's code.
patch0 Mar 8, 2022
98e8033
Silence our friend, Rubocop
patch0 Mar 8, 2022
568a58c
Add in a mass of mocks to allow tests to pass
patch0 Mar 8, 2022
5051ed5
Bump version number
patch0 Mar 8, 2022
aa43f97
Also bump the Gemfile
patch0 Mar 8, 2022
4776f28
Merge pull request #5 from RaspberryPiFoundation/find-and-use-the-def…
patch0 Mar 8, 2022
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
56 changes: 56 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
version: 2.1

jobs:
rubocop:
docker:
- image: 'cimg/base:2021.10'
parameters:
ruby-version:
type: string
steps:
- checkout
- ruby/install:
version: << parameters.ruby-version >>
- ruby/install-deps
- ruby/rubocop-check:
format: progress
label: Inspecting with Rubocop

test:
docker:
- image: 'cimg/base:2021.10'
parameters:
ruby-version:
type: string
steps:
- checkout
- ruby/install:
version: << parameters.ruby-version >>
- ruby/install-deps
- ruby/rspec-test
- store_artifacts:
path: coverage

orbs:
ruby: circleci/ruby@1

workflows:
code_quality:
jobs:
- rubocop:
matrix:
parameters:
ruby-version: ["2.7", "3.0"]
filters:
branches:
ignore:
- master
- main
test:
jobs:
- test:
matrix:
parameters:
ruby-version: ["2.7", "3.0"]

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/pkg/
/spec/reports/
/tmp/
/vendor/

# rspec failure tracking
.rspec_status
Expand Down
190 changes: 15 additions & 175 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,179 +1,19 @@
AllCops:
TargetRubyVersion: 2.2


# Indent private/protected/public as deep as method definitions
AccessModifierIndentation:
EnforcedStyle: outdent
SupportedStyles:
- outdent
- indent

# Align the elements of a hash literal if they span more than one line.
AlignHash:
# Alignment of entries using hash rocket as separator. Valid values are:
#
# key - left alignment of keys
# 'a' => 2
# 'bb' => 3
# separator - alignment of hash rockets, keys are right aligned
# 'a' => 2
# 'bb' => 3
# table - left alignment of keys, hash rockets, and values
# 'a' => 2
# 'bb' => 3
EnforcedHashRocketStyle: key
# Alignment of entries using colon as separator. Valid values are:
#
# key - left alignment of keys
# a: 0
# bb: 1
# separator - alignment of colons, keys are right aligned
# a: 0
# bb: 1
# table - left alignment of keys and values
# a: 0
# bb: 1
EnforcedColonStyle: key

# Allow safe assignment in conditions.
AssignmentInCondition:
AllowSafeAssignment: true

BlockNesting:
Max: 3

BracesAroundHashParameters:
EnforcedStyle: no_braces
SupportedStyles:
- braces
- no_braces

# Indentation of `when`.
CaseIndentation:
EnforcedStyle: case
SupportedStyles:
- case
- end
IndentOneStep: false

# Checks formatting of special comments
CommentAnnotation:
Keywords:
- TODO
- FIXME
- OPTIMIZE
- HACK
- REVIEW

# Use empty lines between defs.
EmptyLineBetweenDefs:
# If true, this parameter means that single line method definitions don't
# need an empty line between them.
AllowAdjacentOneLineDefs: false

Encoding:
Enabled: true

# Align ends correctly.
Lint/EndAlignment:
# The value `keyword` means that `end` should be aligned with the matching
# keyword (if, while, etc.).
# The value `variable` means that in assignments, `end` should be aligned
# with the start of the variable on the left hand side of `=`. In all other
# situations, `end` should still be aligned with the keyword.
EnforcedStyleAlignWith: variable
SupportedStylesAlignWith:
- keyword
- variable
---
inherit_from: .rubocop_todo.yml

# Checks use of for or each in multiline loops.
For:
EnforcedStyle: each
SupportedStyles:
- for
- each

HashSyntax:
EnforcedStyle: ruby19
SupportedStyles:
- ruby19
- hash_rockets

LambdaCall:
EnforcedStyle: call
SupportedStyles:
- call
- braces

MethodDefParentheses:
EnforcedStyle: require_parentheses
SupportedStyles:
- require_parentheses
- require_no_parentheses

MethodName:
EnforcedStyle: snake_case
SupportedStyles:
- snake_case
- camelCase

NumericLiterals:
MinDigits: 10

# Allow safe assignment in conditions.
ParenthesesAroundCondition:
AllowSafeAssignment: true

RedundantReturn:
# When true allows code like `return x, y`.
AllowMultipleReturnValues: false

Semicolon:
# Allow ; to separate several expressions on the same line.
AllowAsExpressionSeparator: false

TrailingCommaInLiteral:
EnforcedStyleForMultiline: no_comma
SupportedStylesForMultiline:
- comma
- no_comma

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: no_comma
SupportedStylesForMultiline:
- comma
- no_comma
AllCops:
TargetRubyVersion: "2.7"
NewCops: enable
Exclude:
- "bin/**/*"
- "vendor/**/*"
- "spec/db/contentful_migrations/*.rb"

# TrivialAccessors doesn't require exact name matches and doesn't allow
# predicated methods by default.
TrivialAccessors:
ExactNameMatch: false
AllowPredicates: false
Whitelist:
- to_ary
- to_a
- to_c
- to_enum
- to_h
- to_hash
- to_i
- to_int
- to_io
- to_open
- to_path
- to_proc
- to_r
- to_regexp
- to_str
- to_s
- to_sym
Style/Documentation:
Enabled: false

VariableName:
EnforcedStyle: snake_case
SupportedStyles:
- snake_case
- camelCase
Metrics/BlockLength:
Exclude:
- '*.gemspec'
- "spec/**/*_spec.rb"

WordArray:
Enabled: False
50 changes: 50 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2021-11-10 17:01:10 UTC using RuboCop version 1.22.3.
# 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: 1
Lint/IneffectiveAccessModifier:
Exclude:
- 'lib/contentful_migrations/migrator.rb'

# Offense count: 2
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 23

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 110

# Offense count: 1
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 11

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 17

# Offense count: 2
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
MaxOptionalParameters: 4
Max: 6

# Offense count: 1
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 12

# Offense count: 1
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'lib/contentful_migrations/migration_content_type.rb'
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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 contentful-migrations.gemspec
gemspec
Loading