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

Add rubocop #38

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
2 changes: 2 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prettier friendly markdownlint config (all formatting rules disabled)
extends: markdownlint/style/prettier
7 changes: 7 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
31 changes: 31 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.6
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.6.3
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- [email protected]
- [email protected]
- [email protected]
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
actions:
enabled:
- trunk-upgrade-available
11 changes: 11 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
gemspec

gem "appraisal"
gem "rubocop", "~> 1.66"

Check notice on line 6 in Gemfile

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/StringLiterals)

[new] Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check notice on line 6 in Gemfile

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/StringLiterals)

[new] Prefer single-quoted strings when you don't need string interpolation or special symbols.

gem "rubocop-rspec", "~> 3.1"

Check notice on line 8 in Gemfile

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/StringLiterals)

[new] Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check notice on line 8 in Gemfile

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/StringLiterals)

[new] Prefer single-quoted strings when you don't need string interpolation or special symbols.

gem "rubocop-performance", "~> 1.22"

Check notice on line 10 in Gemfile

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/StringLiterals)

[new] Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check notice on line 10 in Gemfile

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/StringLiterals)

[new] Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem 'ammeter', '~> 1.1.2'

Check notice on line 11 in Gemfile

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Bundler/OrderedGems)

[new] Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem `ammeter` should appear before `rubocop-performance`.
gem 'rake'
gem 'rspec'
gem 'sqlite3', '~> 1.4'
gem 'vcr'
gem 'webmock'
9 changes: 9 additions & 0 deletions lib/salesforce_ar_sync.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'salesforce_ar_sync/engine'

Check failure on line 1 in lib/salesforce_ar_sync.rb

View check run for this annotation

Trunk.io / Trunk Check

rubocop

Incorrect formatting, autoformat by running 'trunk fmt'
require 'salesforce_ar_sync/version'
require 'salesforce_ar_sync/extenders/salesforce_syncable'
require 'salesforce_ar_sync/soap_handler/base'
Expand All @@ -16,6 +16,15 @@
def self.setup
yield self
end

def someBadRuby_code

Check notice on line 20 in lib/salesforce_ar_sync.rb

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Naming/MethodName)

[new] Use snake_case for method names.
puts "This is a bad method";

Check notice on line 21 in lib/salesforce_ar_sync.rb

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/Semicolon)

[new] Do not use semicolons to terminate expressions.

Check notice on line 21 in lib/salesforce_ar_sync.rb

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/StringLiterals)

[new] Prefer single-quoted strings when you don't need string interpolation or special symbols.


Check notice on line 23 in lib/salesforce_ar_sync.rb

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Layout/EmptyLines)

[new] Extra blank line detected.
return

return "Return value"

Check warning on line 26 in lib/salesforce_ar_sync.rb

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Lint/UnreachableCode)

[new] Unreachable code detected.

Check notice on line 26 in lib/salesforce_ar_sync.rb

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/RedundantReturn)

[new] Redundant `return` detected.

Check notice on line 26 in lib/salesforce_ar_sync.rb

View check run for this annotation

Trunk.io / Trunk Check

rubocop(Style/StringLiterals)

[new] Prefer single-quoted strings when you don't need string interpolation or special symbols.
end
end

if defined?(ActiveRecord::Base)
Expand Down
91 changes: 91 additions & 0 deletions rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
require:
- rubocop-rspec
- rubocop-performance

AllCops:
NewCops: enable
# Exclude:
# - config/**/*
ExtraDetails: enable

# Ruby

Layout/LineLength:
Max: 120

Layout/MultilineMethodCallBraceLayout:
EnforcedStyle: new_line

Lint/AmbiguousBlockAssociation:
AllowedMethods: [change not_change]

Metrics/AbcSize:
Severity: warning
CountRepeatedAttributes: false # potential change

Metrics/ClassLength:
Max: 300
Details: >-
Look for ways to decrease class size by pulling logic into services, concerns, etc.

Metrics/MethodLength:
CountAsOne: [array, hash, heredoc, method_call]

Metrics/CyclomaticComplexity:
Severity: warning
Details: >-
Look for ways to simplify/refactor the method. Pull logic out into more specific methods.

Metrics/ModuleLength:
Enabled: false

Metrics/PerceivedComplexity:
Severity: warning
Details: >-
Look for ways to simplify/refactor the method. Pull logic out into more specific methods.

Style/AndOr:
EnforcedStyle: always
Details: >-
And/Or methods have unexpected complexity attached to them. Try not to use them.

Style/Documentation:
Enabled: false

Style/FrozenStringLiteralComment:
Details: >-
Add `# frozen_string_literal: true` to the top of the file.
Frozen string literals help the memory profile of the application by making strings immutable and register a single time.

Style/NumericLiterals:
Severity: warning

# RSpec

RSpec/DescribeClass:
Exclude:
- "**/spec/features/**/*"
- "**/spec/requests/**/*"
- "**/spec/routing/**/*"
- "**/spec/system/**/*"
- "**/spec/views/**/*"
IgnoredMetadata:
type:
- request
- routing
- view
- feature
- system
- task

RSpec/ExampleLength:
CountAsOne:
- array
- heredoc
- hash

RSpec/NestedGroups:
Max: 5

RSpec/PredicateMatcher:
Enabled: false
14 changes: 3 additions & 11 deletions salesforce_ar_sync.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,20 @@ require File.expand_path('lib/salesforce_ar_sync/version', __dir__)

Gem::Specification.new do |gem|
gem.authors = ['Michael Halliday', 'Nick Neufeld', 'Andrew Coates', 'Devon Noonan', 'Liam Nediger']
gem.email = ['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
gem.email = ['[email protected]', '[email protected]', '[email protected]',
'[email protected]', '[email protected]']
gem.description = 'ActiveRecord extension & rails engine for syncing data with Salesforce.com'
gem.summary = 'ActiveRecord extension & rails engine for syncing data with Salesforce.com'
gem.homepage = 'http://github.com/InfoTech/'

gem.files = Dir['README.md', 'LICENSE', 'lib/**/*', 'app/**/*', 'config/**/*']
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = 'salesforce_ar_sync'
gem.require_paths = ['lib']
gem.version = SalesforceArSync::VERSION

gem.add_dependency 'actionpack-xml_parser'
gem.add_dependency 'rails', '>= 5'
gem.add_dependency 'restforce', '~> 5.0.5'
gem.add_dependency 'rexml', '~> 3.2'

gem.add_development_dependency 'ammeter', '~> 1.1.2'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'sqlite3', '~> 1.4'
gem.add_development_dependency 'vcr'
gem.add_development_dependency 'webmock'

gem.add_runtime_dependency 'restforce', '~> 5.0.5'
end