61 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
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Markus Reiter
fe4ef62aa9
Hide #inspect in docs. 2024-04-26 13:20:05 +02:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
adfd12cfd0 Enable more typing 2023-03-21 21:42:51 -07:00
Issy Long
0c86425d6a
rubocop: Drop "o" from Naming/MethodParameterName allowlist
- I couldn't figure out what this would stand for, so I asked on Slack
  if anyone had better ideas otherwise I'd go with "ostrich" or
  "octopus". Rylan suggested "option", which is very sensible.
2023-03-11 00:17:29 +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
Sam Ford
dac82eb2c2
Options: Add #to_s method
`Options` objects are converted to a string in some circumstances but
this produces output like `#<Options:0x0000000102592c90>`.

For example, formulae.brew.sh contains analytics entries with
incomprehensible names like `adns #<Options:0x0000000102592c90>`.
This shortcoming is apparent when compared to other entries like
`adns --HEAD`.

The `Option` class has a `#to_s` method that returns the `flag`, so
this commit simply adds an `Options#to_s` method that calls `#to_s`
on each `Option` object in `@options` and joins them using spaces.
This should produce more useful output when an `Options` object is
converted to a string (e.g., `--first --second`).
2023-01-19 12:40:50 -05:00
Bo Anderson
abfbb46678
Freeze formula definition once first instance is created 2022-08-31 20:40:42 +01:00
Bo Anderson
e49a338896
Implement caching for dependency expansion 2021-03-20 16:56:00 +00:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid
dba1cfbec9
options: handle nil array.
Fixes #8835
2020-10-02 13:48:26 +01:00
Mike McQuaid
2e5272d04c Deprecate/disable code for Homebrew 2.5.0.
Do the usual "disable deprecations" and "uncomment pending deprecations"
dance and delete/deprecate/disable relevant/related code.
2020-09-03 10:34:22 +01:00
Markus Reiter
5540eac625 Refactor and document Options. 2020-08-19 10:40:33 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Andrew Janke
e0a8a79921 Style fixes for Rubocop 0.57.1 2018-06-30 19:40:14 -04:00
Mike McQuaid
9fca172d03 Fix HOMEBREW_RUBY_WARNINGS="-w"
Fix various circular requirements, method redefinitions, etc.
2018-04-07 20:28:56 +01:00
Mike McQuaid
cf5fdeef1d Rubocop: manual rule fixes. 2017-09-24 21:23:59 +01:00
Markus Reiter
0ab750bf24 Use module_function for commands. 2016-10-02 00:24:47 +02:00
Markus Reiter
e851c9bf6c Style/Alias: Prefer alias. 2016-09-23 18:19:53 +02:00
Markus Reiter
52ff988530 Fix RuboCop CaseEquality. 2016-09-23 15:30:06 +02:00
Baptiste Fontaine
b7e98b129c cmd/options.rb: move common code in options.rb
Closes Homebrew/homebrew#47423.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-12-27 22:16:46 +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
Elliot Saba
6a1f829cfa Ensure that equals options get parsed properly
Options such as --userimg=<path> should be parsed as an option with an
equals in its name ("userimg=") and without the path argument in
Option.name

Closes Homebrew/homebrew#34219.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2014-11-15 17:17:50 -06:00
Mike McQuaid
02e10beb7c Add deprecated_option to software_spec.
Allows remapping one option name to another and updates build options
and flags accordingly.
2014-10-19 13:58:52 +01:00
Mike McQuaid
da0a65356d Add DeprecatedOption class.
Used to capture options that are being renamed.
2014-10-19 13:58:52 +01:00
Jack Nagel
977ae5f27d Collapse iteration to a map 2014-08-29 19:38:32 -05:00
Jack Nagel
750d7bb2c8 Options internals no longer need to support switches 2014-08-29 19:38:32 -05:00
Jack Nagel
6885f588d0 Move handling of leading dashes to Options.create 2014-08-29 19:38:32 -05:00
Jack Nagel
f7f8ca45fc Remove to_str from Option
We no longer need implicit conversion of options to strings.
2014-08-27 14:08:14 -05:00
Jack Nagel
af3d551de7 Options no longer needs deep-copy semantics
Follow-up to 23d90a6a187a57fbdf4eeac146993e3b37c3d4d9.
2014-08-20 19:05:49 -05:00
Jack Nagel
ae4b9fffd4 Avoid hardcoding the class name 2014-08-13 23:45:48 -05:00
Jack Nagel
2311181b54 Remove Options#concat 2014-08-13 18:16:25 -05:00
Jack Nagel
268cd143be Replace Options.coerce with an alternate constructor 2014-08-13 11:09:57 -05:00
Jack Nagel
094c184b12 Remove unused branches from Options.coerce 2014-08-13 11:09:57 -05:00
Mike McQuaid
00d1bb8d12 Revert "Remove unused branches from Options.coerce"
This reverts commit cee42c339e7632eab15111e2c4e6c121ace6f9e2.
2014-08-13 08:45:07 +01:00
Mike McQuaid
a61c3615d2 Revert "Replace Options.coerce with an alternate constructor"
This reverts commit 8d2ef974a3a87bf4207f71ccb8a7b4776e16a016.
2014-08-13 08:45:06 +01:00
Jack Nagel
25395c6de6 Replace Options.coerce with an alternate constructor 2014-08-12 23:55:28 -05:00
Jack Nagel
0a2be32d80 Remove unused branches from Options.coerce 2014-08-12 23:55:28 -05:00
Jack Nagel
8039107afb Default to the empty string instead of nil 2014-08-07 00:48:13 -05:00
Jack Nagel
9e7f5dc261 Merge instead of calling << in a loop 2014-07-07 09:15:56 -05:00
Jack Nagel
aad09a5a63 Option does not need to be Comparable 2014-07-03 19:29:18 -05:00
Jack Nagel
3f6827374f Use to_a definition from Enumerable 2014-07-01 21:26:41 -05:00
Jack Nagel
fbefa76ce2 Always use class.name to build inspect strings 2014-07-01 18:39:15 -05:00
Jack Nagel
14aa1de33c Fix warning under Ruby 2.2 2014-06-09 15:04:15 -05:00
Jack Nagel
b2ccbfe6af Add set union to Options 2014-02-27 14:22:42 -06:00