49 Commits

Author SHA1 Message Date
Douglas Eichelberger
2b29c498fa s/blk/block 2023-08-07 17:26:46 -07:00
Douglas Eichelberger
864f31e52a Forward block argument 2023-08-04 16:20:56 -07:00
Douglas Eichelberger
efd02b956d Revert "Revert "Make inreplace a purely static method""
This reverts commit 8656caa67ce2dd9ec6484969b183c1fd7805451e.
2023-08-04 16:20:38 -07:00
Alexander Bayandin
8656caa67c
Revert "Make inreplace a purely static method" 2023-08-03 16:16:19 +01:00
Douglas Eichelberger
da33049c69 Resolve Style/OptionalBooleanParameter violation 2023-08-02 14:47:06 -07:00
Douglas Eichelberger
2ad87f87d5 Make inreplace a purely static method 2023-08-02 09:44:18 -07:00
Douglas Eichelberger
b26c0917c7 Widen collection type in super call 2023-08-01 09:33:04 -07:00
Douglas Eichelberger
8d8dac0de4 Narrow member type of inreplace paths enumerable 2023-08-01 09:22:48 -07:00
Douglas Eichelberger
c7369b7ea9 Strict type string_inreplace_extension 2023-07-23 15:56:26 -07:00
Carlo Cabrera
fa384b7cc3
utils/inreplace: fix typechecking error
Fixes

        TypeError: Parameter 'before': Expected type T.nilable(T.any(Regexp, String)), got type Pathname with value #<Pathname:/opt/homebrew/Cellar/php@8.1/8.1.21/lib/php>
      Caller: /opt/homebrew/Library/Homebrew/formula.rb:2484
      Definition: /opt/homebrew/Library/Homebrew/utils/inreplace.rb:48

https://github.com/Homebrew/homebrew-core/actions/runs/5635089949/job/15266014851#step:3:1737
2023-07-23 18:23:04 +08:00
Douglas Eichelberger
11a9086b89 Fix inreplace sig
Implicit Pathname strings strike again
2023-07-21 20:02:59 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
200b5cad6a Minor YARD improvements 2023-04-05 10:06:45 -07:00
Sean Molenaar
95080ebbb7
inreplace: style fixes
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2022-08-08 16:18:06 +02:00
Sean Molenaar
12d31853ab
inreplace: fix map 2022-08-08 14:01:44 +02:00
Sean Molenaar
03a489bf78
brew.rb: tell users to fix head issues with inreplace 2022-08-07 13:34:56 +02:00
Rylan Polster
2e4185a525
Fix brew typecheck 2021-12-24 21:15:21 -05:00
Rylan Polster
2e6b6ab3a2
Fix style 2021-12-24 21:15:21 -05:00
Seeker
fbafaff4fe rubocop: require braces for Sorbet sig 2021-01-18 16:52:45 -08:00
Jonathan Chang
ce45868973 Improve documentation and add type signatures. 2021-01-11 10:40:59 +11:00
Markus Reiter
0424940496 Add types for ENV extensions. 2020-11-23 02:06:37 +01:00
Jonathan Chang
9f77ac35b6 Fix type error for inreplace.
`inreplace "file.c", "a", "b"` is a common idiom in
formula install blocks.
2020-10-19 13:57:12 +11:00
Markus Reiter
61b79318ed Move include Kernel into .rbi files again and split up existing .rbi files. 2020-10-10 19:10:58 +02:00
Markus Reiter
318091cccc Move StringInreplaceExtension into separate file. 2020-10-10 15:06:19 +02:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
cc3eceb04f Fix inreplace signature. 2020-09-19 02:03:56 +02:00
Markus Reiter
caa73877c0 Refactor and document Inreplace. 2020-08-23 04:48:19 +02:00
Mike McQuaid
3a91c37e66
Fix RuboCop checks. 2020-08-19 17:12:32 +01:00
Seeker
01dec9c6a8 utils/inreplace: add inreplace_pairs 2020-08-17 03:18:24 -07:00
vidusheeamoli
fd382d2ecd srb: set utils/inreplace.rb to true and refactor
- Sorbet gives preference to class methods over methods defined in
  included modules, hence Sorbet was unavailable to resolve the
definition of the gsub! method.
- The gsub! method in StringInreplaceExtension conflicts with the definition in String.
- This PR refactors the call to the gsub! method so that a custom object
  is exposed instead of a string.
2020-07-26 12:43:31 +05:30
Alexander Bayandin
b7b5a60f86 utils/inreplace: do not allow to use empty list of files 2019-11-21 16:49:06 +00:00
Mike McQuaid
fc6bd2ea1c
Fixup more frozen string handling. 2019-04-20 14:07:29 +09:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
EricFromCanada
20167e5f1b Adjust comments to tidy API docs output. 2018-10-18 21:42:43 -04:00
Mike McQuaid
80d75bc0d8
Homebrew/.rubocop: tweak rules.
Adjust the rules based on the current codebase. Remove various enable,
disables and default values that are unnecessary. Add more comments
explaining why. Make minor changes needed to enable a few more rules.
2018-09-02 20:15:09 +01:00
ilovezfs
ac7a593730 InreplaceError: fix undefined method crash
When the first parameter to inreplace was an array, and the replacement
failed, InreplaceError would end up crashing with an undefined method
exception because the order of operations resulted in super not being
passed the value of the entire inject block.
2017-01-12 07:22:34 -08:00
Mike McQuaid
ecf46b841b utils/inreplace: fix Rubocop warnings. 2016-09-11 19:13:00 +01:00
Xu Cheng
a8566c9848 various: eliminate the usage of any? (#638)
`any?` is not the opposite of `empty?`. Besides the case that
`[false, nil].any?` will return false, `any?`(O(n)) has much worse
performance than `empty?`(O(1)).
2016-08-05 22:01:32 +08:00
ilovezfs
45bfd2b94a inreplace: support for audit arg in non-block form
Provides feature parity between the block and non-block forms of
inreplace by creating a four-argument version of the non-block form,
where the fourth argument is an optional Boolean value, defaulting to
true, which specifies whether a failed inreplace should cause an
InreplaceError error to be raised. The fourth argument is passed along
to StringInreplaceExtension#gsub!, which already supports an optional
audit_result argument.

This resolves the Catch-22 that single replacements aren't permissible
in the block form (in that they now cause `brew audit` to complain), but
the audit_result argument is not available in the non-block form.

Closes #552.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
2016-07-18 09:24:08 -07:00
Mike McQuaid
2c959a7d58 More API documentation.
And remove the documented stuff from the `example-formula.rb`.

Closes Homebrew/homebrew#43241.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-29 15:43:16 +01:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Jack Nagel
aaaab946ec Make inreplace errors fatal
Closes Homebrew/homebrew#32649.
Closes Homebrew/homebrew#32703.
2014-09-28 01:11:31 -05:00
Jack Nagel
4fd63dc4f8 Expose inreplace as a class method 2014-06-18 19:25:35 -05:00
Jack Nagel
7b389fbfed Replace files atomically in inreplace 2014-03-26 16:07:49 -05:00
Jack Nagel
4fe0be37c0 Drop intermediate variable 2014-03-26 16:07:49 -05:00
Mike McQuaid
be3e60fc95 inreplace: odie for Homebrew developers. 2013-11-12 15:44:30 +00:00
Shaun Jackman
91e6c993f8 inreplace: Open the file as binary
Closes Homebrew/homebrew#22628.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2013-09-17 13:58:34 -05:00
Jason Whittle
2c23e71be3 let inreplace take a symbol
As discussed in https://github.com/mxcl/homebrew/pull/21936

Closes Homebrew/homebrew#21942.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2013-08-17 07:40:27 -07:00
Jack Nagel
c8e79c3309 Move inreplace off of Object
Closes Homebrew/homebrew#21163.
2013-07-12 16:23:06 -05:00