diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 0000000..15966d0 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,9 @@ +*out +*logs +*actions +*notifications +*tools +plugins +user_trunk.yaml +user.yaml +tmp diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 0000000..b40ee9d --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,2 @@ +# Prettier friendly markdownlint config (all formatting rules disabled) +extends: markdownlint/style/prettier diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml new file mode 100644 index 0000000..184e251 --- /dev/null +++ b/.trunk/configs/.yamllint.yaml @@ -0,0 +1,7 @@ +rules: + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 0000000..123b464 --- /dev/null +++ b/.trunk/trunk.yaml @@ -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: + - node@18.12.1 + - python@3.10.8 + - ruby@3.1.4 +# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) +lint: + enabled: + - rubocop@1.39.0 + - brakeman@5.4.0 + - checkov@3.2.257 + - git-diff-check + - markdownlint@0.42.0 + - prettier@3.3.3 + - trufflehog@3.82.6 + - yamllint@1.35.1 +actions: + enabled: + - trunk-upgrade-available diff --git a/Gemfile b/Gemfile index ea7339b..29dcda3 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,14 @@ source 'https://rubygems.org' gemspec gem "appraisal" +gem "rubocop", "~> 1.66" + +gem "rubocop-rspec", "~> 3.1" + +gem "rubocop-performance", "~> 1.22" +gem 'ammeter', '~> 1.1.2' +gem 'rake' +gem 'rspec' +gem 'sqlite3', '~> 1.4' +gem 'vcr' +gem 'webmock' diff --git a/lib/salesforce_ar_sync.rb b/lib/salesforce_ar_sync.rb index 5149448..c686103 100644 --- a/lib/salesforce_ar_sync.rb +++ b/lib/salesforce_ar_sync.rb @@ -16,6 +16,15 @@ module SalesforceArSync def self.setup yield self end + + def someBadRuby_code + puts "This is a bad method"; + + + return + + return "Return value" + end end if defined?(ActiveRecord::Base) diff --git a/rubocop.yml b/rubocop.yml new file mode 100644 index 0000000..424fc6c --- /dev/null +++ b/rubocop.yml @@ -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 diff --git a/salesforce_ar_sync.gemspec b/salesforce_ar_sync.gemspec index 1bc06fe..9d68a08 100644 --- a/salesforce_ar_sync.gemspec +++ b/salesforce_ar_sync.gemspec @@ -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 = ['mhalliday@infotech.com', 'nneufeld@infotech.com', 'acoates@infotech.com', 'dnoonan@infotech.com', 'lnediger@infotech.com'] + gem.email = ['mhalliday@infotech.com', 'nneufeld@infotech.com', 'acoates@infotech.com', + 'dnoonan@infotech.com', 'lnediger@infotech.com'] 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