diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ae3e7e..87bb6e2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,10 +14,10 @@ jobs: strategy: matrix: ruby: - - '2.7.5' - '3.0.3' - '3.1.2' - '3.2.2' + - '3.4.2' steps: - uses: actions/checkout@v3 diff --git a/.rubocop.yml b/.rubocop.yml index 7150ef1..df46685 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,10 @@ AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 inherit_from: - - https://dbdrive.github.io/triebwerk/rubocop_common.yml + - .rubocop_common.yml RSpec/NestedGroups: Exclude: - 'spec/lib/thingsboard/api/base_spec.rb' - - 'spec/lib/thingsboard/device_api/base_spec.rb' \ No newline at end of file + - 'spec/lib/thingsboard/device_api/base_spec.rb' diff --git a/.rubocop_common.yml b/.rubocop_common.yml new file mode 100644 index 0000000..b91d0b3 --- /dev/null +++ b/.rubocop_common.yml @@ -0,0 +1,409 @@ +plugins: + - rubocop-rspec + +AllCops: + NewCops: enable + Exclude: + - 'bin/**/*' + - 'config/**/*' + - 'db/**/*' + - 'node_modules/**/*' + - 'tmp/**/*' + - 'vendor/**/*' + - 'utils/**/*' + SuggestExtensions: false + +########## BUNDLER +Bundler/OrderedGems: + Enabled: false + +########## FACTORY BOT + +FactoryBot/SyntaxMethods: + Enabled: false + +########## LAYOUT +Layout/DotPosition: + EnforcedStyle: leading + +Layout/EmptyLinesAroundModuleBody: + Enabled: false + +Layout/EmptyLinesAroundClassBody: + Enabled: false + +Layout/ExtraSpacing: + # We use extra spacing deliberately to make table-like information more + # readable. This cop is not smart enough to always recognize the intent. + Enabled: false + +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +Layout/HashAlignment: + EnforcedColonStyle: table + EnforcedHashRocketStyle: table + +Layout/LineLength: + AutoCorrect: false + Max: 120 + AllowedPatterns: ['\A\s*#'] + +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Layout/SpaceBeforeBrackets: + # We are using a lot of method calls without parentheses and use an array as + # an argument. Those calls would be broken + Enabled: false + +########## LINT +# Disabled as a suggestion from https://github.com/rubocop-hq/rubocop/issues/4222 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'spec/**/*.rb' + +Lint/EmptyWhen: + Enabled: false + +Lint/DuplicateElsifCondition: + Enabled: false + +Lint/DuplicateRequire: + Enabled: false + +Lint/DuplicateRescueException: + Enabled: false + +Lint/EmptyConditionalBody: + Enabled: false + +Lint/EmptyFile: + Enabled: false + +Lint/FloatComparison: + Enabled: false + +Lint/HashCompareByIdentity: + Enabled: false + +Lint/IdentityComparison: + Enabled: false + +Lint/MissingSuper: + Enabled: false + +Lint/MixedRegexpCaptureTypes: + Enabled: false + +Lint/NoReturnInBeginEndBlocks: + Enabled: false + +Lint/OutOfRangeRegexpRef: + Enabled: false + +Lint/RedundantSafeNavigation: + Enabled: false + +Lint/SelfAssignment: + Enabled: false + +Lint/SymbolConversion: + # Both "string_#{interpolation}".to_sym and :"string_#{interpolation}"" have their place. + Enabled: false + +Lint/TopLevelReturnWithArgument: + Enabled: false + +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false + +Lint/UnreachableLoop: + Enabled: false + +Lint/UselessMethodDefinition: + Enabled: false + +Lint/UselessTimes: + Enabled: false + +########## METRICS +Metrics/AbcSize: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/BlockLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false + +########## NAMING +Naming/InclusiveLanguage: + Enabled: false + Severity: info + +Naming/PredicatePrefix: + # Renaming `has_something?` to `something?` obfuscates whether it is a "is-a" or + # a "has-a" relationship. + Enabled: false + +Naming/PredicateMethod: + # Too many false positives in our code base. + Enabled: false + +Naming/MethodParameterName: + Enabled: false + +Naming/VariableNumber: + Enabled: false + +Naming/MemoizedInstanceVariableName: + Exclude: + - 'app/controllers/**/*' + - 'spec/controllers/**/*' + +########## STYLE +Style/Documentation: + Enabled: false + +Style/EmptyElse: + EnforcedStyle: empty + +Style/FrozenStringLiteralComment: + EnforcedStyle: always + Exclude: + - 'spec/**/*' + +Style/IfUnlessModifier: + Enabled: false + +# Requires Ruby 3.1 +Style/NestedFileDirname: + Enabled: false + +Style/NumericPredicate: + EnforcedStyle: comparison + +Style/SymbolArray: + EnforcedStyle: brackets + +Style/NegatedIf: + Enabled: false + +Style/EmptyMethod: + Enabled: false + +Style/EmptyStringInsideInterpolation: + Enabled: false + +Style/CollectionQuerying: + Enabled: false + +Style/FormatStringToken: + Enabled: false + +Style/GuardClause: + Enabled: false + +Style/MultilineTernaryOperator: + Enabled: false + +Style/DoubleNegation: + Enabled: false + +Style/SingleLineBlockParams: + Enabled: false + +Style/RedundantCondition: + Enabled: false + +Style/TrailingUnderscoreVariable: + Enabled: false + +Style/MultilineBlockChain: + Enabled: false + +Style/AsciiComments: + Enabled: false + +Style/RedundantReturn: + Enabled: false + +Style/ZeroLengthPredicate: + Enabled: false + +Style/TernaryParentheses: + EnforcedStyle: require_parentheses_when_complex + +Style/FloatDivision: + Enabled: false + +Style/CommentedKeyword: + Enabled: false + +Style/AccessorGrouping: + Enabled: false + +Style/BisectedAttrAccessor: + Enabled: false + +Style/CaseLikeIf: + Enabled: false + +Style/ClassEqualityComparison: + Enabled: false + +Style/CombinableLoops: + Enabled: false + +Style/ExplicitBlockArgument: + Enabled: false + +Style/ExponentialNotation: + Enabled: false + +Style/GlobalStdStream: + Enabled: false + +Style/HashAsLastArrayItem: + Enabled: false + +Style/HashLikeCase: + Enabled: false + +Style/KeywordParametersOrder: + Enabled: false + +Style/OptionalBooleanParameter: + Enabled: false + +Style/RedundantArgument: + Enabled: false + +Style/RedundantAssignment: + Enabled: false + +Style/RedundantFetchBlock: + Enabled: false + +Style/RedundantFileExtensionInRequire: + Enabled: false + +Style/RedundantRegexpCharacterClass: + Enabled: false + +Style/RedundantRegexpEscape: + Enabled: false + +Style/RedundantSelfAssignment: + Enabled: false + +Style/SignalException: + # When running rubocop with autocorrect (-a) + # this changes our tests for failing operations + # it { is_expected.to fail.with_error(:foobar) } + # to + # it { is_expected.to raise.with_error(:foobar) } + # + # which of course does not work ... + Exclude: + - '**/*_spec.rb' + - 'spec/support/*.rb' + +Style/SingleArgumentDig: + Enabled: false + +Style/SlicingWithRange: + Enabled: false + +Style/SoleNestedConditional: + Enabled: false + +Style/StringConcatenation: + Enabled: false + +Style/WordArray: + Enabled: false + +Style/RegexpLiteral: + Enabled: false + +Style/YodaExpression: + Enabled: false + +# ----------------------------------------------------------------------------- +# RuboCop RSpec +RSpec/AnyInstance: + Enabled: false + +RSpec/BeEmpty: + Enabled: false + +RSpec/BeEql: + Enabled: false + +RSpec/ContextWording: + Enabled: false + +RSpec/EmptyLineAfterFinalLet: + Enabled: false + +RSpec/ExampleLength: + Enabled: false + +RSpec/ImplicitSubject: + EnforcedStyle: single_statement_only + +RSpec/IndexedLet: + Enabled: false + +RSpec/LetSetup: + Enabled: false + +RSpec/MatchArray: + Enabled: false + +RSpec/MessageSpies: + EnforcedStyle: receive + +RSpec/MultipleExpectations: + Enabled: false + +RSpec/MultipleMemoizedHelpers: + Enabled: false + +RSpec/NamedSubject: + Enabled: false + +RSpec/ReceiveMessages: + Enabled: false + +RSpec/SortMetadata: + Enabled: false + +RSpec/StubbedMock: + Enabled: false + +RSpec/VariableName: + EnforcedStyle: snake_case + AllowedPatterns: + - '^X-' + - 'Authorization' + +# ----------------------------------------------------------------------------- +# RuboCop FactoryBot +FactoryBot/ExcessiveCreateList: + # We know what we're doing. + Enabled: false diff --git a/.ruby-version b/.ruby-version index be94e6f..4d9d11c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.2 +3.4.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 30af63a..d2ffc4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ ## [Unreleased] + +## [0.1.2] - 2023-08-01 + +- Update to Ruby 3.4 +- Update to Activesupport 8.1 ready for Rails 8.1 + +## [0.1.1] - 2022-08-01 + - Added links to original Thingsboard API docs in README.md ## [0.1.0] - 2022-07-27 diff --git a/Gemfile b/Gemfile index 40cefe2..47491c3 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group 'development' do gem 'rake', '~> 13.0' gem 'rspec', '~> 3.0' - gem 'rubocop', '~> 1.35' + gem 'rubocop', '~> 1.78.0' gem 'rubocop-rspec' gem 'webmock' end diff --git a/lib/thingsboard.rb b/lib/thingsboard.rb index b3aa8f2..18d6d53 100644 --- a/lib/thingsboard.rb +++ b/lib/thingsboard.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative 'thingsboard/version' +require 'active_support' require 'active_support/configurable' module Thingsboard diff --git a/lib/thingsboard/version.rb b/lib/thingsboard/version.rb index 6e7312e..177e3dc 100644 --- a/lib/thingsboard/version.rb +++ b/lib/thingsboard/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Thingsboard - VERSION = '0.1.1' + VERSION = '0.1.2' end diff --git a/thingsboard-ruby.gemspec b/thingsboard-ruby.gemspec index 9d8f5a5..e49ea24 100644 --- a/thingsboard-ruby.gemspec +++ b/thingsboard-ruby.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |spec| spec.homepage = 'https://github.com/ioki-mobility/thingsboard-ruby' spec.license = 'MIT' - spec.required_ruby_version = '>= 2.7.5' + spec.required_ruby_version = '>= 3.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. @@ -39,7 +39,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.add_dependency 'activesupport', '>= 6.1', '< 8.0' + spec.add_dependency 'activesupport', '>= 6.1', '< 9.0' spec.add_dependency 'faraday', '~> 2.7' spec.metadata['rubygems_mfa_required'] = 'true'