Skip to content

Commit

Permalink
Merge pull request #91 from Mapotempo/add_rubocop
Browse files Browse the repository at this point in the history
Add rubocop initial
  • Loading branch information
giallon committed Jun 26, 2024
2 parents bb15650 + 4a9de9d commit d8842ca
Show file tree
Hide file tree
Showing 64 changed files with 5,157 additions and 4,738 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Linters

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
rubocop:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 2.7
- name: Run rubocop
run: bundle exec rubocop
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ vendor
couchbase

*.gem
rubocop_cache
17 changes: 17 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
inherit_from: .rubocop_todo.yml

inherit_gem:
mapotempo_rubocop:
- rubocop-default.yml

require:
- rubocop-rspec
- rubocop-rake

AllCops:
TargetRubyVersion: 2.7
CacheRootDirectory: rubocop_cache
Exclude:
- 'tmp/**/*'
- 'bin/**/*'
- 'vendor/**/*'
273 changes: 273 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-06-26 13:45:40 UTC using RuboCop version 1.56.4.
# 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: 8
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/has_many_spec.rb'
- 'spec/type_nested_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods.
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
Lint/RedundantSafeNavigation:
Exclude:
- 'lib/couchbase-orm.rb'

# Offense count: 4
# Configuration parameters: IgnoreImplicitReferences.
Lint/ShadowedArgument:
Exclude:
- 'lib/couchbase-orm/relation.rb'

# Offense count: 2
# Configuration parameters: AllowComments, AllowNil.
Lint/SuppressedException:
Exclude:
- 'lib/couchbase-orm/views.rb'
- 'spec/relation_spec.rb'

# Offense count: 5
# Configuration parameters: AllowKeywordBlockArguments.
Lint/UnderscorePrefixedVariableName:
Exclude:
- 'lib/couchbase-orm/relation.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/UselessAssignment:
Exclude:
- 'lib/couchbase-orm.rb'
- 'spec/base_spec.rb'

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 27

# Offense count: 1
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 4

# Offense count: 9
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 82

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 138

# Offense count: 3
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 8

# Offense count: 1
# Configuration parameters: AllowedNames.
# AllowedNames: module_parent
Naming/ClassAndModuleCamelCase:
Exclude:
- 'lib/couchbase-orm/relation.rb'

# Offense count: 2
Naming/ConstantName:
Exclude:
- 'lib/couchbase-orm/id_generator.rb'
- 'lib/couchbase-orm/views.rb'

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/couchbase-orm.rb'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'lib/rails/generators/couchbase_orm/config/config_generator.rb'
- 'lib/rails/generators/couchbase_orm_generator.rb'
- 'spec/support.rb'

# Offense count: 3
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'spec/**/*'
- 'lib/couchbase-orm/associations.rb'
- 'lib/couchbase-orm/base.rb'
- 'lib/couchbase-orm/utilities/has_many.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SafeMultiline.
Performance/DeleteSuffix:
Exclude:
- 'lib/couchbase-orm/extensions/string.rb'

# Offense count: 12
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/BeEq:
Exclude:
- 'spec/index_spec.rb'
- 'spec/relation_spec.rb'
- 'spec/type_spec.rb'

# Offense count: 4
RSpec/BeforeAfterAll:
Exclude:
- '**/spec/spec_helper.rb'
- '**/spec/rails_helper.rb'
- '**/spec/support/**/*.rb'
- 'spec/has_many_spec.rb'
- 'spec/n1ql_spec.rb'
- 'spec/relation_nested_spec.rb'
- 'spec/relation_spec.rb'

# Offense count: 3
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/attribute_dynamic_spec.rb'
- 'spec/base_spec.rb'

# Offense count: 21
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/collection_proxy_spec.rb'
- 'spec/id_generator_spec.rb'
- 'spec/type_nested_spec.rb'
- 'spec/type_spec.rb'

# Offense count: 85
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 39

# Offense count: 2
RSpec/IdenticalEqualityAssertion:
Exclude:
- 'spec/base_spec.rb'

# Offense count: 51
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/has_many_spec.rb'

# Offense count: 8
RSpec/LeakyConstantDeclaration:
Exclude:
- 'spec/has_many_spec.rb'
- 'spec/type_nested_spec.rb'

# Offense count: 1
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 1
RSpec/MultipleDescribes:
Exclude:
- 'spec/type_spec.rb'

# Offense count: 79
RSpec/MultipleExpectations:
Max: 18

# Offense count: 1
# Configuration parameters: AllowedPatterns.
# AllowedPatterns: ^expect_, ^assert_
RSpec/NoExpectationExample:
Exclude:
- 'spec/support.rb'

# Offense count: 1
RSpec/PendingWithoutReason:
Exclude:
- 'spec/base_spec.rb'

# Offense count: 4
RSpec/RepeatedDescription:
Exclude:
- 'spec/type_spec.rb'

# Offense count: 16
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
RSpec/SpecFilePathFormat:
Enabled: false

# Offense count: 6
Style/ClassVars:
Exclude:
- 'lib/couchbase-orm.rb'
- 'lib/couchbase-orm/connection.rb'
- 'lib/couchbase-orm/utilities/ignored_properties.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'lib/couchbase-orm.rb'

# Offense count: 8
Style/MissingRespondToMissing:
Exclude:
- 'lib/couchbase-orm/attributes/dynamic.rb'
- 'lib/couchbase-orm/proxies/bucket_proxy.rb'
- 'lib/couchbase-orm/proxies/collection_proxy.rb'
- 'lib/couchbase-orm/proxies/n1ql_proxy.rb'
- 'lib/couchbase-orm/proxies/results_proxy.rb'
- 'lib/couchbase-orm/relation.rb'

# Offense count: 4
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/couchbase-orm/attributes/dynamic.rb'
- 'lib/couchbase-orm/relation.rb'
- 'lib/couchbase-orm/utilities/join.rb'

# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/couchbase-orm/extensions/string.rb'
- 'lib/couchbase-orm/n1ql.rb'
- 'lib/couchbase-orm/proxies/n1ql_proxy.rb'
- 'lib/couchbase-orm/views.rb'

# Offense count: 29
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 733
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
"https://github.com/#{repo_name}.git"
end
source "https://rubygems.org"
gemspec
source 'https://rubygems.org'
gemspec
8 changes: 5 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# frozen_string_literal: true

require 'rubygems'
require 'rspec/core/rake_task' # testing framework
require 'yard' # yard documentation

# By default we don't run network tests
task :default => :test
task default: :test

RSpec::Core::RakeTask.new(:spec)

desc 'Run all tests'
task :test => [:spec]
task test: [:spec]

YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb', '-', 'README.md']
t.files = ['lib/**/*.rb', '-', 'README.md']
end
Loading

0 comments on commit d8842ca

Please sign in to comment.