Class: RuboCop::Cop::Homebrew::MoveToExtendOS Private
- Defined in:
- rubocops/move_to_extend_os.rb,
sorbet/rbi/dsl/rubo_cop/cop/homebrew/move_to_extend_os.rbi
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
This cop ensures that platform specific code ends up in extend/os, and
that extend/os doesn't contain incorrect or redundant OS checks.
Constant Summary collapse
- NON_EXTEND_OS_MSG =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
"Move `OS.linux?` and `OS.mac?` calls to `extend/os`."
Instance Method Summary collapse
- #extend_offense_message(extend_os, os_method) ⇒ String private
- #on_send(node) ⇒ void private
- #os_linux?(node, **kwargs, &block) ⇒ T.untyped private
- #os_mac?(node, **kwargs, &block) ⇒ T.untyped private
Instance Method Details
#extend_offense_message(extend_os, os_method) ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
21 22 23 24 |
# File 'rubocops/move_to_extend_os.rb', line 21 def (extend_os, os_method) "Don't use `OS.#{os_method}?` in `extend/os/#{extend_os}`, it is " \ "always `#{(extend_os == os_method) ? "true" : "false"}`." end |
#on_send(node) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'rubocops/move_to_extend_os.rb', line 27 def on_send(node) file_path = processed_source.file_path if file_path.include?("extend/os/mac/") add_offense(node, message: ("mac", "mac")) if os_mac?(node) add_offense(node, message: ("mac", "linux")) if os_linux?(node) elsif file_path.include?("extend/os/linux/") add_offense(node, message: ("linux", "mac")) if os_mac?(node) add_offense(node, message: ("linux", "linux")) if os_linux?(node) elsif !file_path.include?("extend/os/") && (os_mac?(node) || os_linux?(node)) add_offense(node, message: NON_EXTEND_OS_MSG) end end |
#os_linux?(node, **kwargs, &block) ⇒ T.untyped
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/rubo_cop/cop/homebrew/move_to_extend_os.rbi', line 10 def os_linux?(node, **kwargs, &block); end |
#os_mac?(node, **kwargs, &block) ⇒ T.untyped
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
13 |
# File 'sorbet/rbi/dsl/rubo_cop/cop/homebrew/move_to_extend_os.rbi', line 13 def os_mac?(node, **kwargs, &block); end |