26 Commits

Author SHA1 Message Date
Michael Cho
dca3e70f98
formula_pin: typed: strict 2024-09-26 14:48:32 -04:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
apainintheneck
db507be41a keg: update sorting by version logic
This updates logic to add a `#scheme_and_version` method to be used
with `.sort_by` and `.max_by`. Using `Keg#version` by itself can be
inaccurate when different version schemes are present. This also
updates the behavior of `Formula#eligible_kegs_for_cleanup` to match
the previous behavior. We were dropping the wrong keg based on the
sort being reversed in a previous PR.
2024-03-31 17:52:32 -07:00
Bo Anderson
dd382487c7
Sort kegs based on version scheme 2024-03-29 23:33:41 +00:00
Issy Long
e9d994622e
rubocop: Drop "f" from Naming/MethodParameterName allowlist
- This either stands for "file" but more often than not "formula".
2023-03-11 00:17:27 +00:00
Seeker
b9854bd4cf rubocops: add unless_multiple_conditions 2021-01-08 10:33:54 -08:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
e5d72ecc6c Document FormulaPin. 2020-08-26 03:13:58 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
2d6ae61314 Re-revert "Fix operator spacing." 2017-06-02 19:22:05 +02:00
Mike McQuaid
6693915399 rubocop --auto-correct all remaining files.
But remove some manual `.freeze`s on constants that shouldn't be
constants.
2016-09-17 16:14:13 +01:00
Mike McQuaid
72d10fff0b Use constants for LinkedKegs/PinnedKegs/Locks.
These definitions are scattered throughout the codebase which makes it
hard to refactor them later (my goal is to move them outside of
HOMEBREW_LIBRARY). Unify their definitions for clearer code and easier
movement later.
2016-09-15 18:28:42 +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
Xu Cheng
fade4af050 formula_pin: use installed_prefixes/installed_kegs 2015-11-29 20:24:30 +08:00
Xu Cheng
02d7abe2ec add Formula#pinned_version 2015-11-16 20:59:12 +08:00
Xu Cheng
b3f0b28025 FormulaPin: pin at max version 2015-11-16 20:59:12 +08:00
Jack Nagel
f222ca04fd Remove pin directory when empty 2014-06-23 22:34:41 -05:00
Jack Nagel
d9e73c9d43 Simplify picking pinned version 2014-06-21 18:32:53 -05:00
Jack Nagel
4e817eaa6c Remove FormulaPin dependency on FileUtils 2014-06-21 18:32:38 -05:00
Jack Nagel
3a0726406b Add tests for FormulaPin and simplify implementation 2013-04-16 01:58:11 -05:00
Jack Nagel
1bad199776 Avoid slow operations in FormulaPin#initialize
A FormulaPin object is created every time Formula is instantiated, so
don't do filesystem operations or Pathname concatenation eagerly.
2013-04-14 21:41:30 -05:00
Jack Nagel
b258bee44e Don't use Pathname#/ in performance-critical code
This method (well, really, #join) is *twice* as slow as simple
concatenation, and shouldn't really be used at all in non-Formula code.
2013-04-14 20:09:20 -05:00
Jack Nagel
ae9060fc54 Remove circular require 2013-04-04 10:53:01 -05:00
Simon Sigurdhsson
4cd95652ea brew-pin: Fix bug in FormulaPin#pinned?
Since `pinned?` was using `File#exists?`, broken symlinks left by force-upgraded
formulae made `pinned?` return false while `pin` returned with an error because
it could not overwrite the broken link. This is fixed by using `File#symlink?`
instead, which returns true for broken symlinks and false only when they do not
exist.

Closes Homebrew/homebrew#18858.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2013-03-31 19:27:17 +01:00
Simon Sigurdhsson
f8a88b5f28 brew-pin: prevent selected formulae from upgrade.
* Added `pin` et. al. to manpage.
* Added `brew pin` to `brew.1` * Added `brew unpin` to `brew.1`
* Added `brew list --pinned` to `brew.1`
* Added information about frozen formulae to `brew upgrade` in `brew.1`
* Added `pin` et.al. to completion scripts.
* Unpin formulae when uninstalling them
* Unpin and re-pin formulae when upgrading (avoids stale symlink)

References Homebrew/homebrew#18386.
Closes Homebrew/homebrew#18515.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2013-03-30 19:50:47 +00:00