Skip to content

Commit

Permalink
Move mixins to obsession namespace to avoid conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromedalbert committed Jan 25, 2025
1 parent baf4f92 commit bfc9360
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
31 changes: 0 additions & 31 deletions lib/rubocop/cop/mixin/helpers.rb

This file was deleted.

File renamed without changes.
33 changes: 33 additions & 0 deletions lib/rubocop/cop/obsession/mixin/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module RuboCop
module Cop
module Obsession
module Helpers
def rails_callback?(callback)
return true if callback == 'validate'

callback.match?(
/
^(before|after|around)
_.*
(action|validation|create|update|save|destroy|commit|rollback)$
/x
)
end

def verb?(string)
short_string = string[2..] if string.start_with?('re')

verbs.include?(string) || verbs.include?(short_string)
end

private

def verbs
@@verbs ||= File.read("#{__dir__}/files/verbs.txt").split
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/rubocop/obsession.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'active_support/core_ext/string/inflections'
require 'rubocop'

require_relative 'cop/mixin/helpers'
require_relative 'cop/obsession/mixin/helpers'
Dir["#{__dir__}/cop/obsession/**/*.rb"].sort.each { |file| require file }
require_relative 'obsession/version'

Expand Down

0 comments on commit bfc9360

Please sign in to comment.