65 Commits

Author SHA1 Message Date
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
Sam Ford
11d6785bea
Add utils/backtrace requires
This is primarily intended to resolve the `uninitialized constant
Utils::Backtrace` error in `formula_versions.rb:60` but I expanded it
to try to cover all existing usage of `Utils::Backtrace`.

I've followed the existing pattern, where `utils/backtrace` is
required in the context of where it's used. Many of these cases use
`Backtrace` in a conditional manner, so I've tried to ensure that the
`require` follows suit.
2024-07-15 17:48:47 -04:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
apainintheneck
85bd4c7e1f utils/backtrace: scrub sorbet-runtime from backtrace
Ever since we started using this at runtime it's been polluting
the backtrace output. This makes it harder to debug errors and
increases the amount of info users have to paste into the box
when filing an issue.

This is a very direct approach. Essentially, we strip out
everything related to the `sorbet-runtime` gem whenever the top
line in the backtrace is unrelated to sorbet-runtime.

The hope is that this will allow errors related to sorbet to
be diagnosed easily while also reducing the backtrace size
for all other types of errors.

Sometimes it is useful to see the full backtrace though.
For those cases, we include the full backtrace when
`--verbose` is passed in and print a warning that the
Sorbet lines have been removed from the backtrace the
first time they are removed.

Note: This requires gems to be set up so that the call to
`Gem.paths.home` works correctly. For that reason, it must
be included after `utils/gems` which is included in
`standalone/load_path` already.
2023-09-21 21:07:22 -07:00
Mike McQuaid
8d1064cdb1
formula_{auditor,versions}: handle sharding.
Ensure that `FormulaVersions` correctly also looks at older paths for
sharded formulae.

While we're here, also cleanup `FormulaVersions` a bit to have more
signatures, cleanup dead code, make more code private, improve
variable naming.
2023-08-14 19:31:15 +01:00
Markus Reiter
486c3765ce
Add --os=all and --arch=all options. 2023-05-17 15:26:46 +02:00
Douglas Eichelberger
0d200944c8 Move nostdout to lone calling class 2023-03-03 08:30:15 -08:00
Chris Wegrzyn
84bbaf9d29
Replace unless with if
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-05-04 11:30:14 -04:00
Chris Wegrzyn
87cd97a52e Don't use --first-parent on core tap 2021-05-04 09:45:31 -04:00
Chris Wegrzyn
9ab44b8b6a bottle: just check origin/HEAD for rebuild 2021-05-03 10:07:30 -04:00
Chris Wegrzyn
056c9bb37f Only consider latest rebuild 2021-05-03 10:07:29 -04:00
Bo Anderson
ac87404c34
formula_versions: try to ignore errors on formula load 2021-04-14 12:37:25 +01:00
EricFromCanada
a6643b4adf fix odebug calls 2021-01-26 12:02:30 -05:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
3851087d01 Document FormulaVersions. 2020-08-26 03:13:58 +02:00
Alexander Bayandin
b43f17b2d0 formula_versions: handle references to too old MacOS in formulae 2020-08-19 09:25:32 +01:00
Markus Reiter
490e503b1b Replace Homebrew.args with Context. 2020-08-06 16:13:14 +02:00
Mike McQuaid
2a94d382ac
audit: make audit_revision_and_version_scheme faster.
This is really, really slow at the moment for a few reasons:
- it goes through the list of revisions twice
- it checks many more revisions than it needs to

Even after these improvements it's still by far the slowest audit so
am also making it a `--git` only audit.

Additionally, to further improve default `brew audit` performance do not
run `brew style` checks when doing `brew audit` with no arguments.

`brew style` can be run quickly and efficiently on all of a tap (and is
cached) so no need to duplicate it here.
2020-06-08 15:00:09 +01:00
Mike McQuaid
bc27e38f18
Remove ARGV.debug?
Replace with `Homebrew.args.debug?`.

Part of #5730.
2020-05-23 14:38:58 +01:00
EricFromCanada
9bfd597991 Format debug messages with odebug 2019-12-02 11:33:19 -05:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
737b84b54b
brew style --fix fixes. 2018-11-02 17:29:23 +00:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Mike McQuaid
e03f07f302 Rubocop 0.53.0 automatic fixes. 2018-03-08 14:10:02 +00:00
Markus Reiter
175ca909ee Clean up code style and remove .rubocop_todo.yml. 2017-10-08 16:10:37 +02:00
Markus Reiter
8ffc77d8e8 Refactor formula_at_revision. 2017-06-04 10:24:16 +02:00
Markus Reiter
f4bacb4444 Fix previous_version_and_checksum method. 2017-05-23 14:11:34 +02:00
Markus Reiter
330307b01a Use FormulaVersions for checksum check. 2017-05-22 02:01:57 +02:00
Mike McQuaid
5647fdb2f9 audit: fix audit of new formulae.
When auditing new formulae without `--new-formula` the
`audit_revision_and_version_scheme` method fails ungracefully. Instead,
set some better defaults so fewer checks are needed.

Fixes #2551.
2017-04-26 11:33:13 +01:00
Mike McQuaid
d5155256ce Fix audit version_scheme and revision checks.
Another attempt at fixing `brew audit` issues around detecting
`revision` and `version_scheme` changes correctly. First done in #1754
and #2086 (reverted in #2099 and #2100).

To ease future debugging a `ph` helper has been added to print a hash
and a series of RSpec tests to verify that the `revision`,
`version_scheme` and `version` formula version audits behave as
expected.

Fixes #1731.
2017-04-23 18:56:22 +01:00
Mike McQuaid
e793e52661 Revert "formula_versions: handle uncommitted formulae." 2017-02-22 08:49:49 +00:00
Mike McQuaid
35ae78f43d formula_versions: handle uncommitted formulae.
Otherwise an uncommitted formula can trigger an invalid `brew audit`
result.

Fixes #1731.
2016-12-30 18:43:50 +00:00
JCount
cfdbe9c645 formula_versions: fix erroneous :stable in version_attributes_map 2016-11-13 22:27:45 -05:00
Mike McQuaid
c78aa43386 audit: fix "version should not decrease" check.
Fix the "version should not decrease" check so it correctly handles
`version_scheme`s.

Fixes #1489.
2016-11-13 13:35:25 +00:00
Markus Reiter
b306f14b97 Rename FormulaMethodDeprecatedError to MethodDeprecatedError. 2016-10-08 13:26:10 +02:00
Markus Reiter
fe2d51e0b9 Fix Style/IfUnlessModifier. 2016-09-23 15:30:07 +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
27ecf588c7 Rename bottle's revision to rebuild. 2016-08-18 17:32:35 +01:00
Mike McQuaid
55ba22e296 formula_versions: add version_attributes_map.
This allows querying multiple attributes in the same way as
`revision_map` did but without duplicating code or repeatedly traversing
history.
2016-08-18 15:04:51 +01:00
Mike McQuaid
e0c8c00e87 formula_versions: set/unset raise_deprecation_exceptions. 2016-08-12 21:07:03 +01:00
Mike McQuaid
0a20ceddcc Revert "formula_versions: also silence stderr." 2016-08-11 17:07:31 +01:00
Mike McQuaid
0b8eab8dac formula_versions: also silence stderr.
We already stop old formula versions printing stdout but this also stops
them printing on stderr for e.g. old deprecation warnings.
2016-08-11 14:08:37 +01:00
ilovezfs
19a77c816e formula_versions: ignore FormulaMethodDeprecatedError
old formula revisions have deprecated elements such as sha1 checksums

Closes #605.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
2016-07-29 23:12:13 -07:00
Xu Cheng
80efb92c35 FormulaVersion: support max depth 2016-01-17 14:52:14 +08:00
Dominyk Tiller
5bc1e0b83a formula_versions: include devel in revision map 2016-01-14 17:53:08 +00:00
Xu Cheng
31da9b266a audit: enforce revision check
Add two checks:
* revision should be reset to 0 for new version.
* revision should not decrease inside the same version interval.

Closes Homebrew/homebrew#48032.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-01-14 15:26:21 +08:00
Xu Cheng
c796198398 formula_versions: tap is a Tap object now 2015-12-09 16:56:59 +08:00
Xu Cheng
11f0979dfb FormulaVersions: load from contents to reduce io 2015-09-06 20:47:04 +08: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
45a71898e8 Isolate formula class namespaces
Closes Homebrew/homebrew#40151.
Closes Homebrew/homebrew#40203.
2015-06-01 19:24:47 -04:00