├── .github └── workflows │ ├── cd.yml │ ├── ci.yml │ ├── stale.yml │ └── triage.yml ├── .gitignore ├── .rubocop.yml ├── .ruby-version ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── Rakefile ├── bin ├── rspec ├── rubocop ├── srb ├── srb-rbi └── tapioca ├── danger-packwerk.gemspec ├── docs ├── check_1.png ├── check_2.png └── update.png ├── lib ├── danger-packwerk.rb ├── danger-packwerk │ ├── basic_reference_offense.rb │ ├── check │ │ ├── default_formatter.rb │ │ └── offenses_formatter.rb │ ├── danger_package_todo_yml_changes.rb │ ├── danger_packwerk.rb │ ├── packwerk_wrapper.rb │ ├── private.rb │ ├── private │ │ ├── git.rb │ │ ├── ownership_information.rb │ │ └── todo_yml_changes.rb │ ├── update │ │ ├── default_formatter.rb │ │ └── offenses_formatter.rb │ ├── version.rb │ └── violation_diff.rb └── danger_plugin.rb ├── sorbet ├── config ├── rbi │ ├── gems │ │ ├── actionview@7.0.4.rbi │ │ ├── activesupport@7.0.4.rbi │ │ ├── addressable@2.8.1.rbi │ │ ├── ast@2.4.2.rbi │ │ ├── better_html@2.0.1.rbi │ │ ├── builder@3.2.4.rbi │ │ ├── claide-plugins@0.9.2.rbi │ │ ├── claide@1.1.0.rbi │ │ ├── code_ownership@1.29.2.rbi │ │ ├── code_teams@1.0.0.rbi │ │ ├── coderay@1.1.3.rbi │ │ ├── colored2@3.1.2.rbi │ │ ├── concurrent-ruby@1.1.10.rbi │ │ ├── constant_resolver@0.2.0.rbi │ │ ├── cork@0.3.0.rbi │ │ ├── crass@1.0.6.rbi │ │ ├── danger-plugin-api@1.0.0.rbi │ │ ├── danger@9.0.0.rbi │ │ ├── diff-lcs@1.5.0.rbi │ │ ├── erubi@1.11.0.rbi │ │ ├── faraday-em_http@1.0.0.rbi │ │ ├── faraday-em_synchrony@1.0.0.rbi │ │ ├── faraday-excon@1.1.0.rbi │ │ ├── faraday-http-cache@2.4.1.rbi │ │ ├── faraday-httpclient@1.0.1.rbi │ │ ├── faraday-multipart@1.0.4.rbi │ │ ├── faraday-net_http@1.0.1.rbi │ │ ├── faraday-net_http_persistent@1.2.0.rbi │ │ ├── faraday-patron@1.0.0.rbi │ │ ├── faraday-rack@1.0.0.rbi │ │ ├── faraday-retry@1.0.3.rbi │ │ ├── faraday@1.10.2.rbi │ │ ├── git@1.12.0.rbi │ │ ├── i18n@1.12.0.rbi │ │ ├── kramdown-parser-gfm@1.1.0.rbi │ │ ├── kramdown@2.4.0.rbi │ │ ├── loofah@2.19.0.rbi │ │ ├── method_source@1.0.0.rbi │ │ ├── minitest@5.16.3.rbi │ │ ├── multipart-post@2.2.3.rbi │ │ ├── nap@1.1.0.rbi │ │ ├── no_proxy_fix@0.1.2.rbi │ │ ├── nokogiri@1.13.8.rbi │ │ ├── octokit@5.6.1.rbi │ │ ├── open4@1.3.4.rbi │ │ ├── packs@0.0.5.rbi │ │ ├── packwerk@2.2.1-e998ef65194de398f0baaf03a0ba33390b30351e.rbi │ │ ├── parallel@1.22.1.rbi │ │ ├── parse_packwerk@0.18.0.rbi │ │ ├── parser@3.1.2.1.rbi │ │ ├── pry@0.14.1.rbi │ │ ├── public_suffix@5.0.0.rbi │ │ ├── racc@1.6.0.rbi │ │ ├── rails-dom-testing@2.0.3.rbi │ │ ├── rails-html-sanitizer@1.4.3.rbi │ │ ├── rainbow@3.1.1.rbi │ │ ├── rake@13.0.6.rbi │ │ ├── rbi@0.0.14.rbi │ │ ├── rchardet@1.8.0.rbi │ │ ├── regexp_parser@2.5.0.rbi │ │ ├── rexml@3.2.5.rbi │ │ ├── rspec-core@3.11.0.rbi │ │ ├── rspec-expectations@3.11.0.rbi │ │ ├── rspec-mocks@3.11.1.rbi │ │ ├── rspec-support@3.11.0.rbi │ │ ├── rspec@3.11.0.rbi │ │ ├── rubocop-ast@1.21.0.rbi │ │ ├── rubocop-sorbet@0.6.8.rbi │ │ ├── rubocop@1.36.0.rbi │ │ ├── ruby-progressbar@1.11.0.rbi │ │ ├── ruby2_keywords@0.0.5.rbi │ │ ├── sawyer@0.9.2.rbi │ │ ├── smart_properties@1.17.0.rbi │ │ ├── spoom@1.1.11.rbi │ │ ├── tapioca@0.8.0.rbi │ │ ├── terminal-table@3.0.2.rbi │ │ ├── thor@1.2.1.rbi │ │ ├── tzinfo@2.0.5.rbi │ │ ├── unicode-display_width@2.3.0.rbi │ │ ├── unparser@0.6.5.rbi │ │ ├── webrick@1.7.0.rbi │ │ ├── yard-sorbet@0.6.1.rbi │ │ └── yard@0.9.27.rbi │ └── todo.rbi └── tapioca │ └── require.rb └── spec ├── danger_packwerk ├── basic_reference_offense_spec.rb ├── danger_package_todo_yml_changes_spec.rb └── danger_packwerk_spec.rb ├── spec_helper.rb └── support ├── custom_matchers.rb └── danger_plugin.rb /.github/workflows/cd.yml: -------------------------------------------------------------------------------- 1 | name: CD 2 | 3 | on: 4 | workflow_run: 5 | workflows: [CI] 6 | types: [completed] 7 | branches: [main] 8 | 9 | jobs: 10 | call-workflow-from-shared-config: 11 | uses: rubyatscale/shared-config/.github/workflows/cd.yml@main 12 | secrets: inherit 13 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | run_tests: 11 | runs-on: ubuntu-latest 12 | strategy: 13 | matrix: 14 | ruby: 15 | - 3.2 16 | - 3.3 17 | - 3.4 18 | env: 19 | BUNDLE_GEMFILE: Gemfile 20 | name: "Run tests: Ruby ${{ matrix.ruby }}" 21 | steps: 22 | - uses: actions/checkout@v4 23 | - name: Set up Ruby ${{ matrix.ruby }} 24 | uses: ruby/setup-ruby@v1 25 | with: 26 | bundler-cache: true 27 | ruby-version: ${{ matrix.ruby }} 28 | - name: Run tests 29 | run: bundle exec rspec 30 | static_type_check: 31 | name: "Type Check" 32 | runs-on: ubuntu-latest 33 | steps: 34 | - uses: actions/checkout@v4 35 | - name: Set up Ruby 36 | uses: ruby/setup-ruby@v1 37 | with: 38 | bundler-cache: true 39 | ruby-version: 3.3 40 | - name: Run static type checks 41 | run: bundle exec srb tc 42 | run_linter: 43 | runs-on: ubuntu-latest 44 | name: "Linter" 45 | steps: 46 | - uses: actions/checkout@v4 47 | - name: Set up Ruby 48 | uses: ruby/setup-ruby@v1 49 | with: 50 | bundler-cache: true 51 | ruby-version: 3.3 52 | - name: Run linter 53 | run: bundle exec rubocop 54 | notify_on_failure: 55 | runs-on: ubuntu-latest 56 | needs: [run_tests, static_type_check, run_linter] 57 | if: ${{ failure() && github.ref == 'refs/heads/main' }} 58 | env: 59 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 60 | SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK 61 | steps: 62 | - uses: slackapi/slack-github-action@v1.25.0 63 | with: 64 | payload: | 65 | { 66 | "text": "${{ github.repository }}/${{ github.ref }}: FAILED\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" 67 | } 68 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues and PRs' 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | jobs: 7 | call-workflow-from-shared-config: 8 | uses: rubyatscale/shared-config/.github/workflows/stale.yml@main 9 | -------------------------------------------------------------------------------- /.github/workflows/triage.yml: -------------------------------------------------------------------------------- 1 | name: Label issues as "triage" 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | jobs: 8 | call-workflow-from-shared-config: 9 | uses: rubyatscale/shared-config/.github/workflows/triage.yml@main 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /tmp/ 2 | 3 | # rspec failure tracking 4 | .rspec_status 5 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - rubocop-sorbet 3 | - rubocop-performance 4 | 5 | AllCops: 6 | TargetRubyVersion: 3.1 7 | NewCops: enable 8 | Exclude: 9 | - bin/**/* 10 | - vendor/**/* 11 | 12 | Sorbet/StrictSigil: 13 | Enabled: true 14 | Exclude: 15 | - spec/**/* 16 | - sorbet/**/* 17 | 18 | Layout/ExtraSpacing: 19 | Enabled: true 20 | Exclude: 21 | - danger-packwerk.gemspec 22 | 23 | Layout/SpaceAroundOperators: 24 | Enabled: true 25 | Exclude: 26 | - danger-packwerk.gemspec 27 | 28 | Sorbet/ValidSigil: 29 | Enabled: true 30 | 31 | Gemspec/RequireMFA: 32 | Enabled: false 33 | 34 | Layout/LineLength: 35 | Enabled: false 36 | 37 | Metrics/BlockLength: 38 | Enabled: false 39 | 40 | Style/Documentation: 41 | Enabled: false 42 | 43 | Style/SignalException: 44 | Enabled: false 45 | 46 | Style/FrozenStringLiteralComment: 47 | Enabled: false 48 | 49 | Style/MultilineBlockChain: 50 | Enabled: false 51 | 52 | Metrics/MethodLength: 53 | Enabled: false 54 | 55 | Metrics/CyclomaticComplexity: 56 | Enabled: false 57 | 58 | Metrics/ModuleLength: 59 | Enabled: false 60 | 61 | Sorbet/FalseSigil: 62 | Enabled: false 63 | 64 | Lint/UnusedMethodArgument: 65 | Enabled: false 66 | 67 | Metrics/AbcSize: 68 | Enabled: false 69 | 70 | Style/GuardClause: 71 | Enabled: false 72 | 73 | Style/NumericPredicate: 74 | Enabled: false 75 | 76 | Metrics/PerceivedComplexity: 77 | Enabled: false 78 | 79 | Metrics/ParameterLists: 80 | Enabled: false 81 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 3.2.2 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | See https://github.com/rubyatscale/danger-packwerk/releases 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual 10 | identity and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at rubyatscale@gusto.com. 63 | All complaints will be reviewed and investigated promptly and fairly. 64 | 65 | All community leaders are obligated to respect the privacy and security of the 66 | reporter of any incident. 67 | 68 | ## Enforcement Guidelines 69 | 70 | Community leaders will follow these Community Impact Guidelines in determining 71 | the consequences for any action they deem in violation of this Code of Conduct: 72 | 73 | ### 1. Correction 74 | 75 | **Community Impact**: Use of inappropriate language or other behavior deemed 76 | unprofessional or unwelcome in the community. 77 | 78 | **Consequence**: A private, written warning from community leaders, providing 79 | clarity around the nature of the violation and an explanation of why the 80 | behavior was inappropriate. A public apology may be requested. 81 | 82 | ### 2. Warning 83 | 84 | **Community Impact**: A violation through a single incident or series of 85 | actions. 86 | 87 | **Consequence**: A warning with consequences for continued behavior. No 88 | interaction with the people involved, including unsolicited interaction with 89 | those enforcing the Code of Conduct, for a specified period of time. This 90 | includes avoiding interactions in community spaces as well as external channels 91 | like social media. Violating these terms may lead to a temporary or permanent 92 | ban. 93 | 94 | ### 3. Temporary Ban 95 | 96 | **Community Impact**: A serious violation of community standards, including 97 | sustained inappropriate behavior. 98 | 99 | **Consequence**: A temporary ban from any sort of interaction or public 100 | communication with the community for a specified period of time. No public or 101 | private interaction with the people involved, including unsolicited interaction 102 | with those enforcing the Code of Conduct, is allowed during this period. 103 | Violating these terms may lead to a permanent ban. 104 | 105 | ### 4. Permanent Ban 106 | 107 | **Community Impact**: Demonstrating a pattern of violation of community 108 | standards, including sustained inappropriate behavior, harassment of an 109 | individual, or aggression toward or disparagement of classes of individuals. 110 | 111 | **Consequence**: A permanent ban from any sort of public interaction within the 112 | community. 113 | 114 | ## Attribution 115 | 116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 117 | version 2.1, available at 118 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 119 | 120 | Community Impact Guidelines were inspired by 121 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 122 | 123 | For answers to common questions about this code of conduct, see the FAQ at 124 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at 125 | [https://www.contributor-covenant.org/translations][translations]. 126 | 127 | [homepage]: https://www.contributor-covenant.org 128 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 129 | [Mozilla CoC]: https://github.com/mozilla/diversity 130 | [FAQ]: https://www.contributor-covenant.org/faq 131 | [translations]: https://www.contributor-covenant.org/translations 132 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | 5 | # Specify your gem's dependencies in danger-packwerk.gemspec 6 | gemspec 7 | 8 | # Override the version of packwerk that is installed by the gemspec 9 | gem 'packwerk', github: 'Shopify/packwerk', branch: 'main' 10 | 11 | # Development dependencies 12 | gem 'pry' 13 | gem 'railties' 14 | gem 'rake' 15 | gem 'rspec', '~> 3.0' 16 | gem 'rubocop' 17 | gem 'rubocop-performance' 18 | gem 'rubocop-sorbet' 19 | gem 'sorbet' 20 | gem 'tapioca' 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Gusto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # danger-packwerk 2 | 3 | `danger-packwerk` integrates [`packwerk`](https://github.com/Shopify/packwerk) with [`danger`](https://github.com/danger/danger) to provide inline comments in PRs related to boundaries in a Rails application. 4 | 5 | ## Installation and Basic Usage 6 | Step 1: Add this line to your `Gemfile` (to whatever group your CI uses, as it is not needed in production) and `bundle install`: 7 | 8 | ```ruby 9 | gem 'danger-packwerk', group: :test 10 | ``` 11 | 12 | Step 2: Add these to your `Dangerfile`: 13 | 14 | ```ruby 15 | packwerk.check 16 | package_todo_yml_changes.check 17 | ``` 18 | 19 | That's it for basic usage! 20 | 21 | ## Advanced Usage 22 | 23 | There are currently two danger checks that ship with `danger-packwerk`: 24 | 1) One that runs `bin/packwerk check` and leaves inline comments in source code on new violations 25 | 2) One that looks at changes to `package_todo.yml` files and leaves inline comments on added violations. 26 | 27 | In upcoming iterations, we will include other danger checks, including: 28 | 1) A danger check that detects changes to `package.yml` files and posts user-configurable messages on the `package.yml` files that are modified. 29 | 2) A danger check that detects changes to `packwerk.yml` files and allows you to specify the action taken when that happens. 30 | 31 | ## packwerk.check 32 | ![This is an image displaying a comment from the Danger github bot after running bin/packwerk check.](docs/check_1.png) 33 | ![This is an image displaying a comment from the Danger github bot after running bin/packwerk check with the "quick suggestions" accordian open](docs/check_2.png) 34 | 35 | Without any configuration, `packwerk.check` should just work. By default, it will post a maximum of 15 messages in a PR and it will not fail the build. 36 | 37 | `packwerk.check` can be configured to in the following ways: 38 | 39 | ### Change the message that displays in the markdown 40 | To customize the message in the GitHub comment, pass in `offenses_formatter` to `packwerk.check` in your `Dangerfile`. Here's a simple example: 41 | ```ruby 42 | class MyFormatter 43 | extend T::Sig 44 | include DangerPackwerk::Check::OffensesFormatter 45 | # Packwerk::ReferenceOffense: https://github.com/Shopify/packwerk/blob/main/lib/packwerk/reference_offense.rb 46 | sig do 47 | override.params( 48 | offenses: T::Array[Packwerk::ReferenceOffense], 49 | repo_link: String, 50 | org_name: String 51 | repo_url_builder: T.nilable(T.proc.params(constant_path: String).returns(String)) 52 | ).returns(String) 53 | end 54 | def format_offenses(offenses, repo_link, org_name, repo_builder_url: nil) 55 | # your logic here 56 | end 57 | end 58 | 59 | packwerk.check(offenses_formatter: MyFormatter.new) 60 | ``` 61 | 62 | If you'd like to keep the default messaging but add some context customized to your organization, you can pass that in as follows: 63 | ```ruby 64 | custom_help_message = "Need help? Check out our internal docs [here](www.example.com)" 65 | packwerk.check(offenses_formatter: DangerPackwerk::Check::DefaultFormatter.new(custom_help_message: custom_help_message)) 66 | ``` 67 | 68 | ### Fail the build on new violations 69 | Simply pass in `fail_build: true` into `check`, as such: 70 | ```ruby 71 | packwerk.check(fail_build: true) 72 | ``` 73 | 74 | If you want to change the default error message, which is `Packwerk violations were detected! Please resolve them to unblock the build.`, then you can also pass in `failure_message`. 75 | 76 | ### Change the max number of comments that will display 77 | If you do not change this, the default max is 15. More information about why we chose this number in the source code. 78 | ```ruby 79 | packwerk.check(max_comments: 3) 80 | ``` 81 | 82 | ### Do something extra when there are packwerk failures 83 | Maybe you want to notify slack or do something else when there are packwerk failures. 84 | 85 | ```ruby 86 | packwerk.check( 87 | # Offenses are a T::Array[Packwerk::ReferenceOffense] => https://github.com/Shopify/packwerk/blob/main/lib/packwerk/reference_offense.rb 88 | on_failure: -> (offenses) do 89 | # Notify slack or otherwise do something extra! 90 | end 91 | ) 92 | ``` 93 | 94 | ## package_todo_yml_changes.check 95 | ![This is an image displaying an inline comment from the Danger github bot.](docs/update.png) 96 | 97 | Without any configuration, `package_todo_yml_changes.check` should just work. By default, it will post a maximum of 15 messages in a PR, using default messaging defined within this gem. 98 | 99 | `package_todo_yml_changes.check` can be configured to in the following ways: 100 | 101 | ### Change the message that displays in the markdown 102 | To customize the message in the GitHub comment, pass in `offenses_formatter` to `package_todo_yml_changes.check` in your `Dangerfile`. Here's a simple example: 103 | ```ruby 104 | class MyFormatter 105 | extend T::Sig 106 | include DangerPackwerk::Update::OffensesFormatter 107 | # DangerPackwerk::BasicReferenceOffense 108 | sig do 109 | override.params( 110 | offenses: T::Array[Packwerk::ReferenceOffense], 111 | repo_link: String, 112 | org_name: String 113 | repo_url_builder: T.nilable(T.proc.params(constant_path: String).returns(String)) 114 | ).returns(String) 115 | end 116 | def format_offenses(offenses, repo_link, org_name, repo_builder_url: nil) 117 | # your logic here 118 | end 119 | end 120 | 121 | package_todo_yml_changes.check(offenses_formatter: MyFormatter.new) 122 | ``` 123 | 124 | If you'd like to keep the default messaging but add some context customized to your organization, you can pass that in as follows: 125 | ```ruby 126 | custom_help_message = "Need help? Check out our internal docs [here](www.example.com)" 127 | package_todo_yml_changes.check(offenses_formatter: DangerPackwerk::Update::DefaultFormatter.new(custom_help_message: custom_help_message)) 128 | ``` 129 | 130 | ### Change the max number of comments that will display 131 | If you do not change this, the default max is 15. More information about why we chose this number in the source code. 132 | ```ruby 133 | package_todo_yml_changes.check(max_comments: 3) 134 | ``` 135 | 136 | ### Do something extra before we leave comments 137 | Maybe you want to notify slack or do something else before we leave comments. 138 | 139 | ```ruby 140 | package_todo_yml_changes.check( 141 | # violation_diff is a DangerPackwerk::ViolationDiff and changed_package_todo_ymls is a T::Array[String] 142 | before_comment: -> (violation_diff, changed_package_todo_ymls) do 143 | # Notify slack or otherwise do something extra! 144 | end 145 | ) 146 | ``` 147 | 148 | ## Development 149 | 150 | We welcome your contributions! Please create an issue or pull request and we'd be happy to take a look. 151 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | require 'rspec/core/rake_task' 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task default: :spec 7 | -------------------------------------------------------------------------------- /bin/rspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'rspec' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 12 | 13 | bundle_binstub = File.expand_path("bundle", __dir__) 14 | 15 | if File.file?(bundle_binstub) 16 | if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") 17 | load(bundle_binstub) 18 | else 19 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 20 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 21 | end 22 | end 23 | 24 | require "rubygems" 25 | require "bundler/setup" 26 | 27 | load Gem.bin_path("rspec-core", "rspec") 28 | -------------------------------------------------------------------------------- /bin/rubocop: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'rubocop' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require 'pathname' 12 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', 13 | Pathname.new(__FILE__).realpath) 14 | 15 | bundle_binstub = File.expand_path('bundle', __dir__) 16 | 17 | if File.file?(bundle_binstub) 18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 19 | load(bundle_binstub) 20 | else 21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 23 | end 24 | end 25 | 26 | require 'rubygems' 27 | require 'bundler/setup' 28 | 29 | load Gem.bin_path('rubocop', 'rubocop') 30 | -------------------------------------------------------------------------------- /bin/srb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'srb' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 12 | 13 | bundle_binstub = File.expand_path("bundle", __dir__) 14 | 15 | if File.file?(bundle_binstub) 16 | if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") 17 | load(bundle_binstub) 18 | else 19 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 20 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 21 | end 22 | end 23 | 24 | require "rubygems" 25 | require "bundler/setup" 26 | 27 | load Gem.bin_path("sorbet", "srb") 28 | -------------------------------------------------------------------------------- /bin/srb-rbi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'srb-rbi' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 12 | 13 | bundle_binstub = File.expand_path("bundle", __dir__) 14 | 15 | if File.file?(bundle_binstub) 16 | if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") 17 | load(bundle_binstub) 18 | else 19 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 20 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 21 | end 22 | end 23 | 24 | require "rubygems" 25 | require "bundler/setup" 26 | 27 | load Gem.bin_path("sorbet", "srb-rbi") 28 | -------------------------------------------------------------------------------- /bin/tapioca: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'tapioca' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require 'pathname' 12 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', 13 | Pathname.new(__FILE__).realpath) 14 | 15 | bundle_binstub = File.expand_path('bundle', __dir__) 16 | 17 | if File.file?(bundle_binstub) 18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 19 | load(bundle_binstub) 20 | else 21 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 22 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 23 | end 24 | end 25 | 26 | require 'rubygems' 27 | require 'bundler/setup' 28 | 29 | load Gem.bin_path('tapioca', 'tapioca') 30 | -------------------------------------------------------------------------------- /danger-packwerk.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative 'lib/danger-packwerk/version' 4 | 5 | Gem::Specification.new do |spec| 6 | spec.name = 'danger-packwerk' 7 | spec.version = DangerPackwerk::VERSION 8 | spec.authors = ['Gusto Engineers'] 9 | spec.email = ['dev@gusto.com'] 10 | spec.description = 'Danger plugin for packwerk.' 11 | spec.summary = 'Danger plugin for packwerk.' 12 | spec.homepage = 'https://github.com/rubyatscale/danger-packwerk' 13 | spec.license = 'MIT' 14 | 15 | if spec.respond_to?(:metadata) 16 | spec.metadata['homepage_uri'] = spec.homepage 17 | spec.metadata['source_code_uri'] = 'https://github.com/rubyatscale/danger-packwerk' 18 | spec.metadata['changelog_uri'] = 'https://github.com/rubyatscale/danger-packwerk/releases' 19 | end 20 | 21 | if spec.respond_to?(:metadata) 22 | spec.metadata['allowed_push_host'] = 'https://rubygems.org' 23 | else 24 | raise 'RubyGems 2.0 or newer is required to protect against ' \ 25 | 'public gem pushes.' 26 | end 27 | 28 | spec.files = Dir['README.md', 'lib/**/*'] 29 | spec.require_paths = ['lib'] 30 | spec.required_ruby_version = '>= 3.1' 31 | 32 | spec.add_dependency 'code_ownership' 33 | spec.add_dependency 'danger-plugin-api', '~> 1.0' 34 | spec.add_dependency 'packs' 35 | spec.add_dependency 'packwerk' 36 | spec.add_dependency 'parse_packwerk' 37 | spec.add_dependency 'sorbet-runtime' 38 | end 39 | -------------------------------------------------------------------------------- /docs/check_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rubyatscale/danger-packwerk/50a3ca7481991771ad438ce86a4a23579222958f/docs/check_1.png -------------------------------------------------------------------------------- /docs/check_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rubyatscale/danger-packwerk/50a3ca7481991771ad438ce86a4a23579222958f/docs/check_2.png -------------------------------------------------------------------------------- /docs/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rubyatscale/danger-packwerk/50a3ca7481991771ad438ce86a4a23579222958f/docs/update.png -------------------------------------------------------------------------------- /lib/danger-packwerk.rb: -------------------------------------------------------------------------------- 1 | # typed: strict # rubocop:disable Naming/FileName: 2 | # frozen_string_literal: true 3 | 4 | # This file exists so clients can call `require 'danger-packwerk'` 5 | require 'sorbet-runtime' 6 | 7 | module DangerPackwerk 8 | PACKAGE_TODO_PATTERN = T.let(/.*?package_todo\.yml\z/, Regexp) 9 | DEPENDENCY_VIOLATION_TYPE = 'dependency' 10 | PRIVACY_VIOLATION_TYPE = 'privacy' 11 | 12 | require 'danger-packwerk/danger_packwerk' 13 | require 'danger-packwerk/danger_package_todo_yml_changes' 14 | require 'danger-packwerk/check/offenses_formatter' 15 | require 'danger-packwerk/check/default_formatter' 16 | require 'danger-packwerk/update/offenses_formatter' 17 | require 'danger-packwerk/update/default_formatter' 18 | end 19 | -------------------------------------------------------------------------------- /lib/danger-packwerk/basic_reference_offense.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | module DangerPackwerk 4 | # 5 | # We call this BasicReferenceOffense as it is intended to have a subset of the interface of Packwerk::ReferenceOffense, located here: 6 | # https://github.com/Shopify/packwerk/blob/a22862b59f7760abf22bda6804d41a52d05301d8/lib/packwerk/reference_offense.rb#L1 7 | # However, we cannot actually construct a Packwerk::ReferenceOffense from `package_todo.yml` alone, since they are normally 8 | # constructed in packwerk when packwerk parses the AST and actually outputs `package_todo.yml`, a process in which some information, 9 | # such as the location where the constant is defined, is lost. 10 | # 11 | class BasicReferenceOffense < T::Struct 12 | class Location < T::Struct 13 | extend T::Sig 14 | 15 | const :file, String 16 | const :line_number, Integer 17 | 18 | # 19 | # These two methods exist so we can use `group_by` to group a `T::Array[BasicReferenceOffense]` by location. 20 | # 21 | sig { params(other: Location).returns(T::Boolean) } 22 | def eql?(other) 23 | file == other.file && line_number == other.line_number 24 | end 25 | 26 | sig { returns(Integer) } 27 | def hash 28 | [file, line_number].hash 29 | end 30 | # 31 | # End method group 32 | # 33 | end 34 | 35 | extend T::Sig 36 | 37 | const :class_name, String 38 | const :file, String 39 | const :to_package_name, String 40 | const :from_package_name, String 41 | const :type, String 42 | const :file_location, Location 43 | 44 | sig { params(package_todo_yml: String).returns(T::Array[BasicReferenceOffense]) } 45 | def self.from(package_todo_yml) 46 | package_todo_yml_pathname = Pathname.new(package_todo_yml) 47 | 48 | from_package = ParsePackwerk.package_from_path(package_todo_yml_pathname) 49 | from_package_name = from_package.name 50 | violations = ParsePackwerk::PackageTodo.from(package_todo_yml_pathname).violations 51 | 52 | # See the larger comment below for more information on why we need this information. 53 | # This is a small optimization that lets us find the location of referenced files within 54 | # a `package_todo.yml` file. Getting this now allows us to avoid reading through the file 55 | # once for every referenced file in the inner loop below. 56 | file_reference_to_line_number_index = T.let({}, T::Hash[String, T::Array[Integer]]) 57 | all_referenced_files = violations.flat_map(&:files).uniq 58 | package_todo_yml_pathname.readlines.each_with_index do |line, index| 59 | # We can use `find` here to exit early since each line will include one path that is unique to that file. 60 | # Paths should not be substrings of each other, since they are all paths relative to the root. 61 | file_on_line = all_referenced_files.find { |file| line.include?(file) } 62 | # Not all lines contain a reference to a file 63 | if file_on_line 64 | file_reference_to_line_number_index[file_on_line] ||= [] 65 | file_reference_to_line_number_index.fetch(file_on_line) << index 66 | end 67 | end 68 | 69 | violations.flat_map do |violation| 70 | # 71 | # We identify two locations associated with this violation. 72 | # First, we find the reference to the constant within the `package_todo.yml` file. 73 | # We know that each constant reference can occur only once per `package_todo.yml` file 74 | # The reason for this is that we know that only one file in the codebase can define a constant, and packwerk's constant_resolver will actually 75 | # raise if this assumption is not true: https://github.com/Shopify/constant_resolver/blob/e78af0c8d5782b06292c068cfe4176e016c51b34/lib/constant_resolver.rb#L74 76 | # 77 | # Second, we find the reference to the specific file that references the constant within the `package_todo.yml` file. 78 | # This can occur multiple times per `package_todo.yml` file, but we know that the very first reference to the file after the class name key will be the one we care 79 | # about, so we take the first instance that occurs after the class is listed. 80 | # 81 | # Note though that since one constant reference in a `package_todo.yml` can be both a privacy and a dependency violation AND it can occur in many files, 82 | # we need to group them. That is -- if `MyPrivateConstant` is both a dependency and a privacy violation AND it occurs in 10 files, that would represent 20 violations. 83 | # Therefore we will group all of those 20 into one message to the user rather than providing 20 messages. 84 | # 85 | _line, class_name_line_number = package_todo_yml_pathname.readlines.each_with_index.find do |line, _index| 86 | # If you have a class `::MyClass`, then you can get a false match if another constant in the file 87 | # is named `MyOtherClass::MyClassThing`. Therefore we include quotes in our match to ensure that we match 88 | # the constant and only the constant. 89 | # Right now `packwerk` `package_todo.yml` files typically use double quotes, but sometimes folks linters change this to single quotes. 90 | # To be defensive, we match against either. 91 | 92 | patterns = [ 93 | /["|']#{violation.class_name}["|']:/, 94 | /\? ["|']#{violation.class_name}["|']$/ # for keys that use explicit mapping syntax 95 | ] 96 | 97 | patterns.any? { |p| line.match?(p) } 98 | end 99 | 100 | if class_name_line_number.nil? 101 | debug_info = { class_name: violation.class_name, to_package_name: violation.to_package_name, type: violation.type } 102 | raise "Unable to find reference to violation #{debug_info} in #{package_todo_yml}" 103 | end 104 | 105 | violation.files.map do |file| 106 | file_line_numbers = file_reference_to_line_number_index.fetch(file, []) 107 | file_line_number = file_line_numbers.select { |index| index > class_name_line_number }.min 108 | raise "Unable to find reference to violation #{{ file: file, to_package_name: violation.to_package_name, type: violation.type }} in #{package_todo_yml}" if file_line_number.nil? 109 | 110 | # We add one to the line number since `each_with_index` is zero-based indexed but Github line numbers are one-based indexed 111 | file_location = Location.new(file: package_todo_yml, line_number: file_line_number + 1) 112 | 113 | BasicReferenceOffense.new( 114 | class_name: violation.class_name, 115 | file: file, 116 | to_package_name: violation.to_package_name, 117 | type: violation.type, 118 | file_location: file_location, 119 | from_package_name: from_package_name 120 | ) 121 | end 122 | end 123 | end 124 | 125 | sig { returns(T::Boolean) } 126 | def privacy? 127 | type == 'privacy' 128 | end 129 | 130 | sig { returns(T::Boolean) } 131 | def dependency? 132 | type == 'dependency' 133 | end 134 | 135 | sig { params(other: BasicReferenceOffense).returns(T::Boolean) } 136 | def ==(other) 137 | other.class_name == class_name && 138 | other.file == file && 139 | other.to_package_name == to_package_name && 140 | other.type == type 141 | end 142 | 143 | sig { params(other: BasicReferenceOffense).returns(T::Boolean) } 144 | def eql?(other) 145 | self == other 146 | end 147 | 148 | sig { returns(Integer) } 149 | def hash 150 | [class_name, file, to_package_name, type].hash 151 | end 152 | end 153 | end 154 | -------------------------------------------------------------------------------- /lib/danger-packwerk/check/default_formatter.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | require 'code_ownership' 4 | 5 | module DangerPackwerk 6 | module Check 7 | class DefaultFormatter 8 | include OffensesFormatter 9 | extend T::Sig 10 | 11 | sig do 12 | params( 13 | custom_help_message: T.nilable(String) 14 | ).void 15 | end 16 | def initialize(custom_help_message: nil) 17 | @custom_help_message = custom_help_message 18 | end 19 | 20 | sig do 21 | override.params( 22 | offenses: T::Array[Packwerk::ReferenceOffense], 23 | repo_link: String, 24 | org_name: String, 25 | repo_url_builder: T.nilable(T.proc.params(constant_path: String).returns(String)) 26 | ).returns(String) 27 | end 28 | def format_offenses(offenses, repo_link, org_name, repo_url_builder: nil) 29 | reference_offense = T.must(offenses.first) 30 | violation_types = offenses.map(&:violation_type) 31 | referencing_file = reference_offense.reference.relative_path 32 | referencing_file_pack = ParsePackwerk.package_from_path(referencing_file).name 33 | # We remove leading double colons as they feel like an implementation detail of packwerk. 34 | constant_name = reference_offense.reference.constant.name.delete_prefix('::') 35 | 36 | constant_source_package_name = reference_offense.reference.constant.package.name 37 | 38 | constant_location = reference_offense.reference.constant.location 39 | constant_source_package = T.must(ParsePackwerk.all.find { |p| p.name == constant_source_package_name }) 40 | constant_source_package_ownership_info = Private::OwnershipInformation.for_package(constant_source_package, org_name) 41 | 42 | disclaimer = 'Before you run `bin/packwerk update-todo`, check out these quick suggestions:' 43 | referencing_code_in_right_pack = "- Does the code you are writing live in the right pack?\n - If not, try `bin/packs move packs/destination_pack #{referencing_file}`" 44 | referenced_code_in_right_pack = "- Does #{constant_name} live in the right pack?\n - If not, try `bin/packs move packs/destination_pack #{constant_location}`" 45 | dependency_violation_message = "- Do we actually want to depend on #{constant_source_package_name}?\n - If so, try `bin/packs add_dependency #{referencing_file_pack} #{constant_source_package_name}`\n - If not, what can we change about the design so we do not have to depend on #{constant_source_package_name}?" 46 | team_to_work_with = constant_source_package_ownership_info.owning_team ? constant_source_package_ownership_info.markdown_link_to_github_members_no_tag : 'the pack owner' 47 | privacy_violation_message = "- Does API in #{constant_source_package.name}/public support this use case?\n - If not, can we work with #{team_to_work_with} to create and use a public API?\n - If `#{constant_name}` should already be public, try `bin/packs make_public #{constant_location}`." 48 | 49 | constant_location_url = 50 | if repo_url_builder 51 | repo_url_builder.call(constant_location) 52 | else 53 | "#{repo_link}/blob/main/#{constant_location}" 54 | end 55 | 56 | if violation_types.include?(::DangerPackwerk::DEPENDENCY_VIOLATION_TYPE) && violation_types.include?(::DangerPackwerk::PRIVACY_VIOLATION_TYPE) 57 | <<~MESSAGE 58 | **Packwerk Violation** 59 | - Type: Privacy :lock: + Dependency :knot: 60 | - Constant: [`#{constant_name}`](#{constant_location_url}) 61 | - Owning pack: #{constant_source_package_name} 62 | #{constant_source_package_ownership_info.ownership_copy} 63 | 64 |
Quick suggestions :bulb: 65 | 66 | #{disclaimer} 67 | #{referencing_code_in_right_pack} 68 | #{referenced_code_in_right_pack} 69 | #{dependency_violation_message} 70 | #{privacy_violation_message} 71 | 72 |
73 | 74 | _#{@custom_help_message}_ 75 | MESSAGE 76 | elsif violation_types.include?(::DangerPackwerk::DEPENDENCY_VIOLATION_TYPE) 77 | <<~MESSAGE 78 | **Packwerk Violation** 79 | - Type: Dependency :knot: 80 | - Constant: [`#{constant_name}`](#{constant_location_url}) 81 | - Owning pack: #{constant_source_package_name} 82 | #{constant_source_package_ownership_info.ownership_copy} 83 | 84 |
Quick suggestions :bulb: 85 | 86 | #{disclaimer} 87 | #{referencing_code_in_right_pack} 88 | #{referenced_code_in_right_pack} 89 | #{dependency_violation_message} 90 | 91 |
92 | 93 | _#{@custom_help_message}_ 94 | MESSAGE 95 | else # violation_types.include?(::DangerPackwerk::PRIVACY_VIOLATION_TYPE) 96 | <<~MESSAGE 97 | **Packwerk Violation** 98 | - Type: Privacy :lock: 99 | - Constant: [`#{constant_name}`](#{constant_location_url}) 100 | - Owning pack: #{constant_source_package_name} 101 | #{constant_source_package_ownership_info.ownership_copy} 102 | 103 |
Quick suggestions :bulb: 104 | 105 | #{disclaimer} 106 | #{referencing_code_in_right_pack} 107 | #{referenced_code_in_right_pack} 108 | #{privacy_violation_message} 109 | 110 |
111 | 112 | _#{@custom_help_message}_ 113 | MESSAGE 114 | end 115 | end 116 | end 117 | end 118 | end 119 | -------------------------------------------------------------------------------- /lib/danger-packwerk/check/offenses_formatter.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | require 'code_ownership' 4 | 5 | module DangerPackwerk 6 | module Check 7 | module OffensesFormatter 8 | extend T::Sig 9 | extend T::Helpers 10 | 11 | interface! 12 | 13 | sig do 14 | abstract.params( 15 | offenses: T::Array[Packwerk::ReferenceOffense], 16 | repo_link: String, 17 | org_name: String, 18 | repo_url_builder: T.nilable(T.proc.params(constant_path: String).returns(String)) 19 | ).returns(String) 20 | end 21 | def format_offenses(offenses, repo_link, org_name, repo_url_builder: nil); end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/danger-packwerk/danger_package_todo_yml_changes.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | # frozen_string_literal: true 3 | 4 | require 'danger' 5 | require 'sorbet-runtime' 6 | require 'danger-packwerk/private' 7 | require 'danger-packwerk/basic_reference_offense' 8 | require 'danger-packwerk/violation_diff' 9 | require 'open3' 10 | 11 | module DangerPackwerk 12 | class DangerPackageTodoYmlChanges < Danger::Plugin 13 | extend T::Sig 14 | 15 | # We choose 5 here because violation additions tend to fall into a bimodal distribution, where most PRs only add a handful (<10) of new violations, 16 | # but there are some that do a rename of an often-used variable, which can change hundreds of violations. 17 | # Therefore we hope to capture the majority case of people making changes to code while not spamming PRs that do a big rename. 18 | # We set a max (rather than unlimited) to avoid GitHub rate limiting and general spam if a PR does some sort of mass rename. 19 | DEFAULT_MAX_COMMENTS = 5 20 | BeforeComment = T.type_alias { T.proc.params(violation_diff: ViolationDiff, changed_package_todo_ymls: T::Array[String]).void } 21 | DEFAULT_BEFORE_COMMENT = T.let(->(violation_diff, changed_package_todo_ymls) {}, BeforeComment) 22 | DEFAULT_VIOLATION_TYPES = T.let([ 23 | DEPENDENCY_VIOLATION_TYPE, 24 | PRIVACY_VIOLATION_TYPE 25 | ].freeze, T::Array[String]) 26 | 27 | sig do 28 | params( 29 | offenses_formatter: T.nilable(Update::OffensesFormatter), 30 | before_comment: BeforeComment, 31 | max_comments: Integer, 32 | violation_types: T::Array[String], 33 | root_path: T.nilable(String) 34 | ).void 35 | end 36 | def check( 37 | offenses_formatter: nil, 38 | before_comment: DEFAULT_BEFORE_COMMENT, 39 | max_comments: DEFAULT_MAX_COMMENTS, 40 | violation_types: DEFAULT_VIOLATION_TYPES, 41 | root_path: nil 42 | ) 43 | offenses_formatter ||= Update::DefaultFormatter.new 44 | repo_link = github.pr_json[:base][:repo][:html_url] 45 | repo_url_builder = ->(constant_path) { "#{repo_link}/blob/#{github.pr_json[:head][:ref]}/#{constant_path}" } 46 | org_name = github.pr_json[:base][:repo][:owner][:login] 47 | 48 | git_filesystem = Private::GitFilesystem.new(git: git, root: root_path || '') 49 | changed_package_todo_ymls = (git_filesystem.modified_files + git_filesystem.added_files + git_filesystem.deleted_files).grep(PACKAGE_TODO_PATTERN) 50 | 51 | violation_diff = DangerPackageTodoYmlChanges.get_violation_diff(violation_types, git: git, root_path: root_path) 52 | 53 | before_comment.call( 54 | violation_diff, 55 | changed_package_todo_ymls.to_a 56 | ) 57 | 58 | current_comment_count = 0 59 | 60 | violation_diff.added_violations.group_by(&:class_name).each_value do |violations| 61 | break if current_comment_count >= max_comments 62 | 63 | location = T.must(violations.first).file_location 64 | 65 | markdown( 66 | offenses_formatter.format_offenses(violations, repo_link, org_name, repo_url_builder: repo_url_builder), 67 | line: location.line_number, 68 | file: git_filesystem.convert_to_filesystem(location.file) 69 | ) 70 | 71 | current_comment_count += 1 72 | end 73 | end 74 | 75 | sig do 76 | params( 77 | violation_types: T::Array[String], 78 | git: Danger::DangerfileGitPlugin, 79 | root_path: T.nilable(String) 80 | ).returns(ViolationDiff) 81 | end 82 | def self.get_violation_diff(violation_types, git:, root_path: nil) 83 | git_filesystem = Private::GitFilesystem.new(git: git, root: root_path || '') 84 | 85 | added_violations, removed_violations = Private::TodoYmlChanges.get_reference_offenses( 86 | violation_types, git_filesystem 87 | ) 88 | 89 | ViolationDiff.new( 90 | added_violations: added_violations, 91 | removed_violations: removed_violations 92 | ) 93 | end 94 | end 95 | end 96 | -------------------------------------------------------------------------------- /lib/danger-packwerk/danger_packwerk.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | # frozen_string_literal: true 3 | 4 | require 'danger' 5 | require 'packwerk' 6 | require 'parse_packwerk' 7 | require 'sorbet-runtime' 8 | require 'danger-packwerk/packwerk_wrapper' 9 | require 'danger-packwerk/private/git' 10 | 11 | module DangerPackwerk 12 | # Note that Danger names the plugin (i.e. anything that inherits from `Danger::Plugin`) by taking the name of the class and gsubbing out "Danger" 13 | # Therefore this plugin is simply called "packwerk" 14 | class DangerPackwerk < Danger::Plugin 15 | extend T::Sig 16 | 17 | # We choose 15 because we want to err on the side of completeness and give users all of the information they need to help make their build pass, 18 | # especially given all violations should fail the build anyways. 19 | # We set a max (rather than unlimited) to avoid GitHub rate limiting and general spam if a PR does some sort of mass rename. 20 | DEFAULT_MAX_COMMENTS = 15 21 | OnFailure = T.type_alias { T.proc.params(offenses: T::Array[Packwerk::ReferenceOffense]).void } 22 | DEFAULT_ON_FAILURE = T.let(->(offenses) {}, OnFailure) 23 | DEFAULT_FAIL = false 24 | DEFAULT_FAILURE_MESSAGE = 'Packwerk violations were detected! Please resolve them to unblock the build.' 25 | DEFAULT_VIOLATION_TYPES = T.let([ 26 | DEPENDENCY_VIOLATION_TYPE, 27 | PRIVACY_VIOLATION_TYPE 28 | ].freeze, T::Array[String]) 29 | 30 | class CommentGroupingStrategy < ::T::Enum 31 | enums do 32 | PerConstantPerLocation = new 33 | PerConstantPerPack = new 34 | end 35 | end 36 | 37 | PerConstantPerPackGrouping = CommentGroupingStrategy::PerConstantPerPack 38 | 39 | # We probably want to check the `include` key of `packwerk.yml`. By default, this value is "**/*.{rb,rake,erb}", 40 | # so we hardcode this in for now. If this blocks a user, we can take that opportunity to read from `packwerk.yml`. 41 | TARGETED_FILES_EXTENSIONS = T.let(%w[.erb .rake .rb].freeze, T::Array[String]) 42 | 43 | sig do 44 | params( 45 | offenses_formatter: T.nilable(Check::OffensesFormatter), 46 | max_comments: Integer, 47 | fail_build: T::Boolean, 48 | failure_message: String, 49 | on_failure: OnFailure, 50 | violation_types: T::Array[String], 51 | grouping_strategy: CommentGroupingStrategy, 52 | root_path: T.nilable(String) 53 | ).void 54 | end 55 | def check( 56 | offenses_formatter: nil, 57 | max_comments: DEFAULT_MAX_COMMENTS, 58 | fail_build: DEFAULT_FAIL, 59 | failure_message: DEFAULT_FAILURE_MESSAGE, 60 | on_failure: DEFAULT_ON_FAILURE, 61 | violation_types: DEFAULT_VIOLATION_TYPES, 62 | grouping_strategy: CommentGroupingStrategy::PerConstantPerLocation, 63 | root_path: nil 64 | ) 65 | offenses_formatter ||= Check::DefaultFormatter.new 66 | repo_link = github.pr_json[:base][:repo][:html_url] 67 | repo_url_builder = ->(constant_path) { "#{repo_link}/blob/#{github.pr_json[:head][:ref]}/#{constant_path}" } 68 | org_name = github.pr_json[:base][:repo][:owner][:login] 69 | 70 | # This is important because by default, Danger will leave a concantenated list of all its messages if it can't find a commentable place in the 71 | # diff to leave its message. This is an especially bad UX because it will be a huge wall of text not connected to the source of the issue. 72 | # Furthermore, dismissing these ensures that something like moving a file from pack to pack does not trigger the danger message. That is, 73 | # the danger message will only be triggered by actual code that someone has actually written in their PR. 74 | # Another example would be if someone changes the list of dependencies of a package (e.g. to resolve a cyclic dependency). This would not 75 | # trigger the warning message, which is good, since we only want to trigger on new code. 76 | github.dismiss_out_of_range_messages 77 | 78 | git_filesystem = Private::GitFilesystem.new(git: git, root: root_path || '') 79 | 80 | # https://github.com/danger/danger/blob/eca19719d3e585fe1cc46bc5377f9aa955ebf609/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb#L80 81 | renamed_files_after = git_filesystem.renamed_files.map { |f| f[:after] } 82 | 83 | targeted_files = (git_filesystem.modified_files + git_filesystem.added_files + renamed_files_after).select do |f| 84 | path = Pathname.new(f) 85 | 86 | # We probably want to check the `include` key of `packwerk.yml`. By default, this value is "**/*.{rb,rake,erb}", 87 | # so we hardcode this in for now. If this blocks a user, we can take that opportunity to read from `packwerk.yml`. 88 | extension_is_targeted = TARGETED_FILES_EXTENSIONS.include?(path.extname) 89 | 90 | # If a file has been modified via a rename, then `git.modified_files` will return an array that includes that file's *original* name. 91 | # Packwerk will ignore input files that do not exist, and when the PR only contains renamed Ruby files, that means packwerk check works 92 | # off of an empty list. It's default behavior in that case is to scan *all* files, which can lead to abnormally long run times. 93 | # To avoid this, we gracefully return if there are no targeted files. 94 | # To avoid false negatives, we also look at renamed files after (above) 95 | file_exists = path.exist? 96 | 97 | extension_is_targeted && file_exists 98 | end 99 | 100 | return if targeted_files.empty? 101 | 102 | current_comment_count = 0 103 | 104 | packwerk_reference_offenses = PackwerkWrapper.get_offenses_for_files(targeted_files.to_a).compact 105 | 106 | renamed_files = git_filesystem.renamed_files.map { |before_after_file| before_after_file[:after] } 107 | 108 | packwerk_reference_offenses_to_care_about = packwerk_reference_offenses.reject do |packwerk_reference_offense| 109 | constant_name = packwerk_reference_offense.reference.constant.name 110 | filepath_that_defines_this_constant = Private.constant_resolver.resolve(constant_name)&.location 111 | # Ignore references that have been renamed 112 | renamed_files.include?(filepath_that_defines_this_constant) || 113 | # Ignore violations that are not in the allow-list of violation types to leave comments for 114 | !violation_types.include?(packwerk_reference_offense.violation_type) 115 | end 116 | 117 | # We group by the constant name, line number, and reference path. Any offenses with these same values should only differ on what type of violation 118 | # they are (privacy or dependency). We put privacy and dependency violation messages in the same comment since they would occur on the same line. 119 | packwerk_reference_offenses_to_care_about.group_by do |packwerk_reference_offense| 120 | case grouping_strategy 121 | when CommentGroupingStrategy::PerConstantPerLocation 122 | [ 123 | packwerk_reference_offense.reference.constant.name, 124 | packwerk_reference_offense.location&.line, 125 | packwerk_reference_offense.reference.relative_path 126 | ] 127 | when CommentGroupingStrategy::PerConstantPerPack 128 | [ 129 | packwerk_reference_offense.reference.constant.name, 130 | ParsePackwerk.package_from_path(packwerk_reference_offense.reference.relative_path) 131 | ] 132 | else 133 | T.absurd(grouping_strategy) 134 | end 135 | end.each_value do |unique_packwerk_reference_offenses| 136 | break if current_comment_count >= max_comments 137 | 138 | current_comment_count += 1 139 | 140 | reference_offense = T.must(unique_packwerk_reference_offenses.first) 141 | line_number = reference_offense.location&.line 142 | referencing_file = reference_offense.reference.relative_path 143 | 144 | message = offenses_formatter.format_offenses(unique_packwerk_reference_offenses, repo_link, org_name, repo_url_builder: repo_url_builder) 145 | markdown(message, file: git_filesystem.convert_to_filesystem(referencing_file), line: line_number) 146 | end 147 | 148 | if current_comment_count > 0 149 | fail(failure_message) if fail_build 150 | 151 | on_failure.call(packwerk_reference_offenses) 152 | end 153 | end 154 | end 155 | end 156 | -------------------------------------------------------------------------------- /lib/danger-packwerk/packwerk_wrapper.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | module DangerPackwerk 4 | # This class wraps packwerk to give us precisely what we want, which is the `Packwerk::ReferenceOffense` from a set of files. 5 | # Note that statically packwerk returns `Packwerk::Offense` from running `bin/packwerk check`. The two types of `Packwerk::Offense` are 6 | # `Packwerk::ReferenceOffense` and `Packwerk::Parsers::ParseResult`.`Packwerk::ReferenceOffense` inherits from `Packwerk::Offense`, and has more info than `Packwerk::Offense`. 7 | # `Packwerk::Parsers::ParseResult` is returned when there is a file parsing issue. We ignore ParseResult types as it's likely that other tests would break along with this Danger check. 8 | # and it is not the intent of this check to look for syntax errors in code. 9 | # 10 | # Also note that we would not need most of this class if there were two changes made to Packwerk: 11 | # 1) It did not raise if no checkable files were found (I think it might make more sense to just return successfully rather than raise). This occurs if the 12 | # input file list is excluded from the user's `exclude` list. In this case, check should return that no errors were found, since those files were not analyzed. 13 | # 2) If the CLI gave a way to get offenses from files without this somewhat hacky way of passing in a formatter that stores the offenses. 14 | class PackwerkWrapper 15 | extend T::Sig 16 | 17 | sig { params(files: T::Array[String]).returns(T::Array[Packwerk::ReferenceOffense]) } 18 | def self.get_offenses_for_files(files) 19 | formatter = OffensesAggregatorFormatter.new 20 | # This is mostly copied from exe/packwerk within the packwerk gem, but we use our own formatters 21 | ENV['RAILS_ENV'] = 'test' 22 | style = Packwerk::OutputStyles::Coloured.new 23 | cli = Packwerk::Cli.new(style: style, offenses_formatter: formatter) 24 | cli.execute_command(['check', *files]) 25 | reference_offenses = formatter.aggregated_offenses.compact.select { |offense| offense.is_a?(Packwerk::ReferenceOffense) } 26 | T.cast(reference_offenses, T::Array[Packwerk::ReferenceOffense]) 27 | rescue SystemExit => e 28 | # Packwerk should probably exit positively here rather than raising an error -- there should be no 29 | # errors if the user has excluded all files being checked. 30 | if e.message == 'No files found or given. Specify files or check the include and exclude glob in the config file.' 31 | [] 32 | else 33 | raise 34 | end 35 | end 36 | 37 | # 38 | # This Packwerk formatter simply collects offenses. Ideally we could accomplish this by calling into public API of the CLI, 39 | # but right now this is the only way to get the raw offenses out of packwerk. 40 | # 41 | class OffensesAggregatorFormatter 42 | extend T::Sig 43 | include Packwerk::OffensesFormatter 44 | 45 | sig { returns(T::Array[Packwerk::Offense]) } 46 | attr_reader :aggregated_offenses 47 | 48 | sig { void } 49 | def initialize 50 | @aggregated_offenses = T.let([], T::Array[Packwerk::ReferenceOffense]) 51 | end 52 | 53 | sig { override.params(offenses: T::Array[T.nilable(Packwerk::Offense)]).returns(String) } 54 | def show_offenses(offenses) 55 | @aggregated_offenses = T.unsafe(offenses) 56 | '' 57 | end 58 | 59 | sig { override.params(offense_collection: Packwerk::OffenseCollection, for_files: T::Set[String]).returns(String) } 60 | def show_stale_violations(offense_collection, for_files) 61 | '' 62 | end 63 | 64 | sig { override.params(strict_mode_violations: T::Array[::Packwerk::ReferenceOffense]).returns(::String) } 65 | def show_strict_mode_violations(strict_mode_violations) 66 | '' 67 | end 68 | 69 | sig { override.returns(::String) } 70 | def identifier 71 | 'danger_packwerk_offenses_aggregator' 72 | end 73 | end 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /lib/danger-packwerk/private.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | require 'danger-packwerk/private/ownership_information' 4 | require 'danger-packwerk/private/todo_yml_changes' 5 | require 'constant_resolver' 6 | 7 | module DangerPackwerk 8 | # 9 | # Anything within the Private module is subject to change. 10 | # 11 | module Private 12 | extend T::Sig 13 | 14 | sig { returns(ConstantResolver) } 15 | def self.constant_resolver 16 | @constant_resolver ||= T.let( 17 | begin 18 | load_paths = Packwerk::RailsLoadPaths.for(Dir.pwd, environment: 'test') 19 | ConstantResolver.new( 20 | root_path: Dir.pwd, 21 | load_paths: T.unsafe(load_paths).keys 22 | ) 23 | end, 24 | T.nilable(ConstantResolver) 25 | ) 26 | end 27 | end 28 | 29 | private_constant :Private 30 | end 31 | -------------------------------------------------------------------------------- /lib/danger-packwerk/private/git.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | require 'code_ownership' 4 | require 'packs' 5 | 6 | # In order to support running danger-packwerk from a non-root filepath, we need 7 | # to wrap some git functions in filesystem wrappers: packwerk runs relative to 8 | # the rails app root, whereas git returns paths on the actual filesystem. 9 | module DangerPackwerk 10 | module Private 11 | class GitFilesystem < T::Struct 12 | extend T::Sig 13 | 14 | const :git, Danger::DangerfileGitPlugin 15 | const :root, String 16 | 17 | sig { returns(T::Array[{ after: String, before: String }]) } 18 | def renamed_files 19 | @git.renamed_files.map do |f| 20 | { 21 | after: convert_file_from_filesystem(f[:after]), 22 | before: convert_file_from_filesystem(f[:before]) 23 | } 24 | end 25 | end 26 | 27 | sig { returns(T::Array[String]) } 28 | def modified_files 29 | convert_from_filesystem(@git.modified_files.to_a) 30 | end 31 | 32 | sig { returns(T::Array[String]) } 33 | def deleted_files 34 | convert_from_filesystem(@git.deleted_files.to_a) 35 | end 36 | 37 | sig { returns(T::Array[String]) } 38 | def added_files 39 | convert_from_filesystem(@git.added_files.to_a) 40 | end 41 | 42 | sig { params(filename_on_disk: String).returns(::Git::Diff::DiffFile) } 43 | def diff(filename_on_disk) 44 | @git.diff[filename_on_disk] 45 | end 46 | 47 | sig { params(path: String).returns(String) } 48 | def convert_to_filesystem(path) 49 | Pathname(@root).join(path).to_s 50 | end 51 | 52 | private 53 | 54 | sig { params(files: T::Array[String]).returns(T::Array[String]) } 55 | def convert_from_filesystem(files) 56 | files.map { |f| convert_file_from_filesystem(f) } 57 | end 58 | 59 | sig { params(file: String).returns(String) } 60 | def convert_file_from_filesystem(file) 61 | Pathname(file).relative_path_from(@root).to_s 62 | end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /lib/danger-packwerk/private/ownership_information.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | require 'code_ownership' 4 | require 'packs' 5 | 6 | module DangerPackwerk 7 | module Private 8 | class OwnershipInformation < T::Struct 9 | extend T::Sig 10 | 11 | const :owning_team, T.nilable(CodeTeams::Team) 12 | const :github_team, T.nilable(String) 13 | const :slack_channel, T.nilable(String) 14 | const :org_name, T.nilable(String) 15 | 16 | sig { params(package: ParsePackwerk::Package, org_name: String).returns(OwnershipInformation) } 17 | def self.for_package(package, org_name) 18 | pack = Packs.find(package.name) 19 | team = pack.nil? ? nil : CodeOwnership.for_package(pack) 20 | 21 | if team.nil? 22 | OwnershipInformation.new 23 | else 24 | OwnershipInformation.new( 25 | owning_team: team, 26 | github_team: team.raw_hash.fetch('github', {}).fetch('team', nil), 27 | slack_channel: team.raw_hash.fetch('slack', {}).fetch('room_for_humans', nil), 28 | org_name: org_name 29 | ) 30 | end 31 | end 32 | 33 | sig { returns(String) } 34 | def ownership_copy 35 | github_team_flow_sensitive = github_team 36 | slack_channel_flow_sensitive = slack_channel 37 | 38 | if owning_team && github_team_flow_sensitive && slack_channel_flow_sensitive 39 | team_slack_link = markdown_link_to_slack_room 40 | "- Owned by #{markdown_link_to_github_members_no_tag} (Slack: #{team_slack_link})" 41 | else 42 | '- This pack is unowned.' 43 | end 44 | end 45 | 46 | sig { returns(String) } 47 | def markdown_link_to_slack_room 48 | "[#{slack_channel}](https://slack.com/app_redirect?channel=#{T.must(slack_channel).delete('#')})" 49 | end 50 | 51 | # 52 | # Note this will NOT tag the team on Github, but it will link 53 | # to the mentioned team's members page. If you want to tag and 54 | # link the team, simply use the string and Github will handle it. 55 | # 56 | sig { returns(String) } 57 | def markdown_link_to_github_members_no_tag 58 | "[#{github_team}](https://github.com/orgs/#{org_name}/teams/#{T.must(github_team).gsub("@#{org_name}/", '')}/members)" 59 | end 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /lib/danger-packwerk/private/todo_yml_changes.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | module DangerPackwerk 4 | module Private 5 | class TodoYmlChanges 6 | extend T::Sig 7 | extend T::Helpers 8 | 9 | sig do 10 | params( 11 | violation_types: T::Array[String], 12 | git_filesystem: GitFilesystem 13 | ).returns([T::Array[BasicReferenceOffense], T::Array[BasicReferenceOffense]]) 14 | end 15 | def self.get_reference_offenses(violation_types, git_filesystem) 16 | added_violations = T.let([], T::Array[BasicReferenceOffense]) 17 | removed_violations = T.let([], T::Array[BasicReferenceOffense]) 18 | 19 | git_filesystem.added_files.grep(PACKAGE_TODO_PATTERN).each do |added_package_todo_yml_file| 20 | # Since the file is added, we know on the base commit there are no violations related to this pack, 21 | # and that all violations from this file are new 22 | added_violations += BasicReferenceOffense.from(added_package_todo_yml_file) 23 | end 24 | 25 | git_filesystem.deleted_files.grep(PACKAGE_TODO_PATTERN).each do |deleted_package_todo_yml_file| 26 | # Since the file is deleted, we know on the HEAD commit there are no violations related to this pack, 27 | # and that all violations from this file are deleted 28 | deleted_violations = get_violations_before_patch_for(git_filesystem, deleted_package_todo_yml_file) 29 | removed_violations += deleted_violations 30 | end 31 | 32 | # The format for git.renamed_files is a T::Array[{after: "some/path/new", before: "some/path/old"}] 33 | renamed_files_before = git_filesystem.renamed_files.map { |before_after_file| before_after_file[:before] } 34 | renamed_files_after = git_filesystem.renamed_files.map { |before_after_file| before_after_file[:after] } 35 | 36 | git_filesystem.modified_files.grep(PACKAGE_TODO_PATTERN).each do |modified_package_todo_yml_file| 37 | # We skip over modified files if one of the modified files is a renamed `package_todo.yml` file. 38 | # This allows us to rename packs while ignoring "new violations" in those renamed packs. 39 | next if renamed_files_before.include?(modified_package_todo_yml_file) 40 | 41 | head_commit_violations = BasicReferenceOffense.from(modified_package_todo_yml_file) 42 | base_commit_violations = get_violations_before_patch_for(git_filesystem, modified_package_todo_yml_file) 43 | added_violations += head_commit_violations - base_commit_violations 44 | removed_violations += base_commit_violations - head_commit_violations 45 | end 46 | 47 | # 48 | # This implementation creates some false negatives: 49 | # That is – it doesn't capture some cases: 50 | # 1) A file has been renamed without renaming a constant. 51 | # That can happen if we change only the autoloaded portion of a filename. 52 | # For example: `packs/foo/app/services/my_class.rb` (defines: `MyClass`) 53 | # is changed to `packs/foo/app/public/my_class.rb` (still defines: `MyClass`) 54 | # 55 | # This implementation also doesn't cover these false positives: 56 | # That is – it leaves a comment when it should not. 57 | # 1) A CONSTANT within a class or module has been renamed. 58 | # e.g. `class MyClass; MY_CONSTANT = 1; end` becomes `class MyClass; RENAMED_CONSTANT = 1; end` 59 | # We would not detect based on file renames that `MY_CONSTANT` has been renamed. 60 | # 61 | renamed_constants = [] 62 | 63 | added_violations.each do |violation| 64 | filepath_that_defines_this_constant = Private.constant_resolver.resolve(violation.class_name)&.location 65 | renamed_constants << violation.class_name if renamed_files_after.include?(filepath_that_defines_this_constant) 66 | end 67 | 68 | relevant_added_violations = added_violations.reject do |violation| 69 | renamed_files_after.include?(violation.file) || 70 | renamed_constants.include?(violation.class_name) || 71 | !violation_types.include?(violation.type) 72 | end 73 | 74 | relevant_removed_violations = removed_violations.select do |violation| 75 | violation_types.include?(violation.type) 76 | end 77 | 78 | [relevant_added_violations, relevant_removed_violations] 79 | end 80 | 81 | sig do 82 | params( 83 | git_filesystem: GitFilesystem, 84 | package_todo_yml_file: String 85 | ).returns(T::Array[BasicReferenceOffense]) 86 | end 87 | def self.get_violations_before_patch_for(git_filesystem, package_todo_yml_file) 88 | # The strategy to get the violations before this PR is to reverse the patch on each `package_todo.yml`. 89 | # A previous strategy attempted to use `git merge-base --fork-point`, but there are many situations where it returns 90 | # empty values. That strategy is fickle because it depends on the state of the `reflog` within the CI suite, which appears 91 | # to not be reliable to depend on. 92 | # 93 | # Instead, just inverting the patch should hopefully provide a more reliable way to figure out what was the state of the file before 94 | # the PR without needing to use git commands that interpret the branch history based on local git history. 95 | # 96 | # We apply the patch to the original file so that we can seamlessly reverse the patch applied to that file (since patches are coupled to 97 | # the files they modify). After parsing the violations from that `package_todo.yml` file with the patch reversed, 98 | # we use a temporary copy of the original file to rewrite to it with the original contents. 99 | # Note that practically speaking, we don't need to rewrite the original contents (since we already fetched the 100 | # original contents above and the CI file system should be ephemeral). However, we do this anyways in case we later change these 101 | # assumptions, or another client's environment is different and expects these files not to be mutated. 102 | 103 | # Keep track of the original file contents. If the original file has been deleted, then we delete the file after inverting the patch at the end, rather than rewriting it. 104 | package_todo_yml_file_copy = (File.read(package_todo_yml_file) if File.exist?(package_todo_yml_file)) 105 | 106 | Tempfile.create do |patch_file| 107 | # Normally we'd use `git.diff_for_file(package_todo_yml_file).patch` here, but there is a bug where it does not work for deleted files yet. 108 | # I have a fix for that here: https://github.com/danger/danger/pull/1357 109 | # Until that lands, I'm just using the underlying implementation of that method to get the diff for a file. 110 | # Note that I might want to use a safe escape operator, `&.patch` and return gracefully if the patch cannot be found. 111 | # However I'd be interested in why that ever happens, so for now going to proceed as is. 112 | # (Note that better yet we'd have observability into these so I can just log under those circumstances rather than surfacing an error to the user, 113 | # but we don't have that quite yet.) 114 | package_todo_filesystem_path = git_filesystem.convert_to_filesystem(package_todo_yml_file) 115 | patch_for_file = git_filesystem.diff(package_todo_filesystem_path).patch 116 | # This appears to be a known issue that patches require new lines at the end. It seems like this is an issue with Danger that 117 | # it gives us a patch without a newline. 118 | # https://stackoverflow.com/questions/18142870/git-error-fatal-corrupt-patch-at-line-36 119 | patch_file << "#{patch_for_file}\n" 120 | patch_file.rewind 121 | # https://git-scm.com/docs/git-apply 122 | _stdout, _stderr, _status = Open3.capture3("git apply --reverse #{patch_file.path}") 123 | # https://www.rubyguides.com/2019/05/ruby-tempfile/ 124 | BasicReferenceOffense.from(package_todo_yml_file) 125 | end 126 | ensure 127 | if package_todo_yml_file_copy 128 | File.write(package_todo_yml_file, package_todo_yml_file_copy) 129 | else 130 | File.delete(package_todo_yml_file) 131 | end 132 | end 133 | end 134 | end 135 | end 136 | -------------------------------------------------------------------------------- /lib/danger-packwerk/update/default_formatter.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | module DangerPackwerk 4 | module Update 5 | class DefaultFormatter 6 | extend T::Sig 7 | include OffensesFormatter 8 | 9 | sig do 10 | params( 11 | custom_help_message: T.nilable(String) 12 | ).void 13 | end 14 | def initialize(custom_help_message: nil) 15 | @custom_help_message = custom_help_message 16 | end 17 | 18 | sig do 19 | override.params( 20 | offenses: T::Array[BasicReferenceOffense], 21 | repo_link: String, 22 | org_name: String, 23 | repo_url_builder: T.nilable(T.proc.params(constant_path: String).returns(String)) 24 | ).returns(String) 25 | end 26 | def format_offenses(offenses, repo_link, org_name, repo_url_builder: nil) 27 | violation = T.must(offenses.first) 28 | referencing_file_pack = ParsePackwerk.package_from_path(violation.file) 29 | # We remove leading double colons as they feel like an implementation detail of packwerk. 30 | constant_name = violation.class_name.delete_prefix('::') 31 | constant_source_package_name = violation.to_package_name 32 | 33 | constant_source_package = T.must(ParsePackwerk.find(constant_source_package_name)) 34 | constant_source_package_owner = Private::OwnershipInformation.for_package(constant_source_package, org_name) 35 | 36 | package_referring_to_constant_owner = Private::OwnershipInformation.for_package(referencing_file_pack, org_name) 37 | 38 | disclaimer = 'We noticed you ran `bin/packwerk update-todo`. Check out [the docs](https://github.com/Shopify/packwerk/blob/main/RESOLVING_VIOLATIONS.md) to see other ways to resolve violations.' 39 | pluralized_violation = offenses.count > 1 ? 'these violations' : 'this violation' 40 | request_to_add_context = "- Could you add some context as a reply here about why we needed to add #{pluralized_violation}?\n" 41 | 42 | dependency_violation_message = "- cc #{package_referring_to_constant_owner.github_team} (#{package_referring_to_constant_owner.markdown_link_to_slack_room}) for the dependency violation.\n" if package_referring_to_constant_owner.owning_team 43 | 44 | privacy_violation_message = "- cc #{constant_source_package_owner.github_team} (#{constant_source_package_owner.markdown_link_to_slack_room}) for the privacy violation.\n" if constant_source_package_owner.owning_team 45 | 46 | if offenses.any?(&:dependency?) && offenses.any?(&:privacy?) 47 | <<~MESSAGE.chomp 48 | Hi again! It looks like `#{constant_name}` is private API of `#{constant_source_package_name}`, which is also not in `#{referencing_file_pack.name}`'s list of dependencies. 49 | #{disclaimer} 50 | 51 | #{request_to_add_context}#{dependency_violation_message}#{privacy_violation_message} 52 | #{@custom_help_message} 53 | MESSAGE 54 | elsif offenses.any?(&:dependency?) 55 | <<~MESSAGE.chomp 56 | Hi again! It looks like `#{constant_name}` belongs to `#{constant_source_package_name}`, which is not in `#{referencing_file_pack.name}`'s list of dependencies. 57 | #{disclaimer} 58 | 59 | #{request_to_add_context}#{dependency_violation_message} 60 | #{@custom_help_message} 61 | MESSAGE 62 | else # violations.any?(&:privacy?) 63 | <<~MESSAGE.chomp 64 | Hi again! It looks like `#{constant_name}` is private API of `#{constant_source_package_name}`. 65 | #{disclaimer} 66 | 67 | #{request_to_add_context}#{privacy_violation_message} 68 | #{@custom_help_message} 69 | MESSAGE 70 | end 71 | end 72 | end 73 | end 74 | end 75 | -------------------------------------------------------------------------------- /lib/danger-packwerk/update/offenses_formatter.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | require 'code_ownership' 4 | 5 | module DangerPackwerk 6 | module Update 7 | module OffensesFormatter 8 | extend T::Sig 9 | extend T::Helpers 10 | 11 | interface! 12 | 13 | sig do 14 | abstract.params( 15 | offenses: T::Array[BasicReferenceOffense], 16 | repo_link: String, 17 | org_name: String, 18 | repo_url_builder: T.nilable(T.proc.params(constant_path: String).returns(String)) 19 | ).returns(String) 20 | end 21 | def format_offenses(offenses, repo_link, org_name, repo_url_builder: nil); end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/danger-packwerk/version.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | # frozen_string_literal: true 3 | 4 | module DangerPackwerk 5 | VERSION = '0.15.0' 6 | end 7 | -------------------------------------------------------------------------------- /lib/danger-packwerk/violation_diff.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | 3 | module DangerPackwerk 4 | # 5 | # This class represents the change in violations between a PR and its base. 6 | # 7 | class ViolationDiff < T::Struct 8 | extend T::Sig 9 | 10 | const :added_violations, T::Array[BasicReferenceOffense] 11 | const :removed_violations, T::Array[BasicReferenceOffense] 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/danger_plugin.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | # frozen_string_literal: true 3 | 4 | require 'danger-packwerk' 5 | -------------------------------------------------------------------------------- /sorbet/config: -------------------------------------------------------------------------------- 1 | --dir 2 | . 3 | --enable-experimental-requires-ancestor 4 | --ignore=/vendor/bundle 5 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/better_html@2.0.1.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `better_html` gem. 5 | # Please instead update this file by running `bin/tapioca gem better_html`. 6 | 7 | module BetterHtml 8 | class << self 9 | def config; end 10 | 11 | # Sets the attribute config 12 | # 13 | # @param value the value to set the attribute config to. 14 | def config=(_arg0); end 15 | 16 | # @yield [config] 17 | def configure; end 18 | end 19 | end 20 | 21 | module BetterHtml::AST; end 22 | 23 | class BetterHtml::AST::Iterator 24 | # @return [Iterator] a new instance of Iterator 25 | def initialize(types, &block); end 26 | 27 | def traverse(node); end 28 | def traverse_all(nodes); end 29 | 30 | class << self 31 | def descendants(root_node, type); end 32 | end 33 | end 34 | 35 | class BetterHtml::AST::Node < ::AST::Node 36 | def descendants(*types); end 37 | 38 | # Returns the value of attribute loc. 39 | def loc; end 40 | 41 | def location; end 42 | end 43 | 44 | class BetterHtml::Config 45 | include ::SmartProperties 46 | extend ::SmartProperties::ClassMethods 47 | 48 | # @return [Boolean] 49 | def javascript_attribute_name?(name); end 50 | 51 | # @return [Boolean] 52 | def javascript_safe_method?(name); end 53 | 54 | # @return [Boolean] 55 | def lodash_safe_javascript_expression?(code); end 56 | end 57 | 58 | class BetterHtml::DontInterpolateHere < ::BetterHtml::InterpolatorError; end 59 | 60 | class BetterHtml::Errors < ::Array 61 | def add(_arg0); end 62 | end 63 | 64 | module BetterHtml::Helpers 65 | def html_attributes(args); end 66 | end 67 | 68 | class BetterHtml::HtmlAttributes 69 | # @return [HtmlAttributes] a new instance of HtmlAttributes 70 | def initialize(data); end 71 | 72 | def to_s; end 73 | end 74 | 75 | class BetterHtml::HtmlError < ::RuntimeError; end 76 | class BetterHtml::InterpolatorError < ::RuntimeError; end 77 | 78 | class BetterHtml::Parser 79 | # @raise [ArgumentError] 80 | # @return [Parser] a new instance of Parser 81 | def initialize(buffer, template_language: T.unsafe(nil)); end 82 | 83 | def ast; end 84 | def inspect; end 85 | def nodes_with_type(*type); end 86 | def parser_errors; end 87 | 88 | # Returns the value of attribute template_language. 89 | def template_language; end 90 | 91 | private 92 | 93 | def build_attribute_name_node(tokens); end 94 | def build_attribute_node(tokens); end 95 | def build_attribute_value_node(tokens); end 96 | def build_cdata_node(tokens); end 97 | def build_comment_node(tokens); end 98 | def build_document_node; end 99 | def build_erb_node(tokens); end 100 | def build_interpolation_node(tokens); end 101 | 102 | # @raise [ArgumentError] 103 | def build_location(enumerable); end 104 | 105 | def build_lodash_node(tokens); end 106 | def build_nameless_attribute_node(tokens); end 107 | def build_node(type, tokens, pre: T.unsafe(nil), post: T.unsafe(nil)); end 108 | def build_tag_attributes_node(tokens); end 109 | def build_tag_name_node(tokens); end 110 | def build_tag_node(tokens); end 111 | def build_text_node(tokens); end 112 | def empty_location; end 113 | def shift_all(tokens, *types); end 114 | def shift_all_with_interpolation(tokens, *types); end 115 | def shift_between(tokens, start_type, end_type); end 116 | def shift_between_with_interpolation(tokens, start_type, end_type); end 117 | def shift_single(tokens, *types); end 118 | def shift_until(tokens, *types); end 119 | def shift_until_with_interpolation(tokens, *types); end 120 | def wrap_token(object); end 121 | def wrap_tokens(enumerable); end 122 | end 123 | 124 | class BetterHtml::Parser::Error < ::BetterHtml::HtmlError 125 | # @return [Error] a new instance of Error 126 | def initialize(message, location:); end 127 | 128 | # Returns the value of attribute location. 129 | def loc; end 130 | 131 | # Returns the value of attribute location. 132 | def location; end 133 | end 134 | 135 | BetterHtml::Parser::INTERPOLATION_TYPES = T.let(T.unsafe(nil), Array) 136 | 137 | class BetterHtml::ParserError < ::RuntimeError 138 | # @return [ParserError] a new instance of ParserError 139 | def initialize(message, position, line, column); end 140 | 141 | # Returns the value of attribute column. 142 | def column; end 143 | 144 | # Returns the value of attribute line. 145 | def line; end 146 | 147 | # Returns the value of attribute position. 148 | def position; end 149 | end 150 | 151 | module BetterHtml::Tokenizer; end 152 | 153 | class BetterHtml::Tokenizer::BaseErb < ::Erubi::Engine 154 | # @raise [ArgumentError] 155 | # @return [BaseErb] a new instance of BaseErb 156 | def initialize(buffer); end 157 | 158 | # Returns the value of attribute current_position. 159 | def current_position; end 160 | 161 | # Returns the value of attribute tokens. 162 | def tokens; end 163 | 164 | private 165 | 166 | def add_code(code); end 167 | def add_erb_tokens(ltrim, indicator, code, rtrim); end 168 | def add_expression(indicator, code); end 169 | def add_token(type, begin_pos, end_pos); end 170 | def append(text); end 171 | end 172 | 173 | BetterHtml::Tokenizer::BaseErb::EXPR_TRIM_MATCHER = T.let(T.unsafe(nil), Regexp) 174 | BetterHtml::Tokenizer::BaseErb::REGEXP_WITHOUT_TRIM = T.let(T.unsafe(nil), Regexp) 175 | BetterHtml::Tokenizer::BaseErb::STMT_TRIM_MATCHER = T.let(T.unsafe(nil), Regexp) 176 | 177 | class BetterHtml::Tokenizer::HtmlErb < ::BetterHtml::Tokenizer::BaseErb 178 | # @return [HtmlErb] a new instance of HtmlErb 179 | def initialize(buffer); end 180 | 181 | def current_position; end 182 | 183 | # Returns the value of attribute parser. 184 | def parser; end 185 | 186 | private 187 | 188 | def add_text(text); end 189 | def append(text); end 190 | end 191 | 192 | class BetterHtml::Tokenizer::HtmlLodash 193 | # @return [HtmlLodash] a new instance of HtmlLodash 194 | def initialize(buffer); end 195 | 196 | def lodash_escape; end 197 | def lodash_escape=(val); end 198 | def lodash_evaluate; end 199 | def lodash_evaluate=(val); end 200 | def lodash_interpolate; end 201 | def lodash_interpolate=(val); end 202 | 203 | # Returns the value of attribute parser. 204 | def parser; end 205 | 206 | # Returns the value of attribute tokens. 207 | def tokens; end 208 | 209 | private 210 | 211 | def add_lodash_tokens(indicator, code); end 212 | def add_text(text); end 213 | def add_token(type, begin_pos: T.unsafe(nil), end_pos: T.unsafe(nil)); end 214 | def scan!; end 215 | def scan_pattern; end 216 | 217 | class << self 218 | def lodash_escape; end 219 | def lodash_escape=(val); end 220 | def lodash_evaluate; end 221 | def lodash_evaluate=(val); end 222 | def lodash_interpolate; end 223 | def lodash_interpolate=(val); end 224 | end 225 | end 226 | 227 | class BetterHtml::Tokenizer::JavascriptErb < ::BetterHtml::Tokenizer::BaseErb 228 | private 229 | 230 | def add_text(text); end 231 | end 232 | 233 | class BetterHtml::Tokenizer::Location < ::Parser::Source::Range 234 | # @raise [ArgumentError] 235 | # @return [Location] a new instance of Location 236 | def initialize(buffer, begin_pos, end_pos); end 237 | 238 | def adjust(begin_pos: T.unsafe(nil), end_pos: T.unsafe(nil)); end 239 | def begin; end 240 | def end; end 241 | def line_range; end 242 | def line_source_with_underline; end 243 | def offset(offset); end 244 | def range; end 245 | def resize(new_size); end 246 | def start_column; end 247 | def start_line; end 248 | def stop_column; end 249 | def stop_line; end 250 | def with(begin_pos: T.unsafe(nil), end_pos: T.unsafe(nil)); end 251 | end 252 | 253 | class BetterHtml::Tokenizer::Token 254 | # @return [Token] a new instance of Token 255 | def initialize(type:, loc:); end 256 | 257 | def inspect; end 258 | 259 | # Returns the value of attribute loc. 260 | def loc; end 261 | 262 | # Returns the value of attribute type. 263 | def type; end 264 | end 265 | 266 | class BetterHtml::Tokenizer::TokenArray 267 | # @return [TokenArray] a new instance of TokenArray 268 | def initialize(list); end 269 | 270 | # @return [Boolean] 271 | def any?; end 272 | 273 | def current; end 274 | 275 | # @return [Boolean] 276 | def empty?; end 277 | 278 | def last; end 279 | def pop; end 280 | def shift; end 281 | def size; end 282 | def trim(type); end 283 | end 284 | 285 | class BetterHtml::UnsafeHtmlError < ::BetterHtml::InterpolatorError; end 286 | BetterHtml::VERSION = T.let(T.unsafe(nil), String) 287 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/builder@3.2.4.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `builder` gem. 5 | # Please instead update this file by running `bin/tapioca gem builder`. 6 | 7 | # THIS IS AN EMPTY RBI FILE. 8 | # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires 9 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/code_teams@1.0.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `code_teams` gem. 5 | # Please instead update this file by running `bin/tapioca gem code_teams`. 6 | 7 | module CodeTeams 8 | class << self 9 | sig { returns(T::Array[::CodeTeams::Team]) } 10 | def all; end 11 | 12 | sig { void } 13 | def bust_caches!; end 14 | 15 | sig { params(name: ::String).returns(T.nilable(::CodeTeams::Team)) } 16 | def find(name); end 17 | 18 | sig { params(dir: ::String).returns(T::Array[::CodeTeams::Team]) } 19 | def for_directory(dir); end 20 | 21 | sig { params(string: ::String).returns(::String) } 22 | def tag_value_for(string); end 23 | 24 | sig { params(teams: T::Array[::CodeTeams::Team]).returns(T::Array[::String]) } 25 | def validation_errors(teams); end 26 | end 27 | end 28 | 29 | class CodeTeams::IncorrectPublicApiUsageError < ::StandardError; end 30 | 31 | class CodeTeams::Plugin 32 | abstract! 33 | 34 | sig { params(team: ::CodeTeams::Team).void } 35 | def initialize(team); end 36 | 37 | class << self 38 | sig { returns(T::Array[T.class_of(CodeTeams::Plugin)]) } 39 | def all_plugins; end 40 | 41 | sig { params(team: ::CodeTeams::Team).returns(T.attached_class) } 42 | def for(team); end 43 | 44 | sig { params(base: T.untyped).void } 45 | def inherited(base); end 46 | 47 | sig { params(team: ::CodeTeams::Team, key: ::String).returns(::String) } 48 | def missing_key_error_message(team, key); end 49 | 50 | sig { params(teams: T::Array[::CodeTeams::Team]).returns(T::Array[::String]) } 51 | def validation_errors(teams); end 52 | 53 | private 54 | 55 | sig { params(team: ::CodeTeams::Team).returns(T.attached_class) } 56 | def register_team(team); end 57 | 58 | sig { returns(T::Hash[T.nilable(::String), T::Hash[::Class, ::CodeTeams::Plugin]]) } 59 | def registry; end 60 | end 61 | end 62 | 63 | module CodeTeams::Plugins; end 64 | 65 | class CodeTeams::Plugins::Identity < ::CodeTeams::Plugin 66 | sig { returns(::CodeTeams::Plugins::Identity::IdentityStruct) } 67 | def identity; end 68 | 69 | class << self 70 | sig { override.params(teams: T::Array[::CodeTeams::Team]).returns(T::Array[::String]) } 71 | def validation_errors(teams); end 72 | end 73 | end 74 | 75 | class CodeTeams::Plugins::Identity::IdentityStruct < ::Struct 76 | def name; end 77 | def name=(_); end 78 | 79 | class << self 80 | def [](*_arg0); end 81 | def inspect; end 82 | def members; end 83 | def new(*_arg0); end 84 | end 85 | end 86 | 87 | class CodeTeams::Team 88 | sig { params(config_yml: T.nilable(::String), raw_hash: T::Hash[T.untyped, T.untyped]).void } 89 | def initialize(config_yml:, raw_hash:); end 90 | 91 | sig { params(other: ::Object).returns(T::Boolean) } 92 | def ==(other); end 93 | 94 | sig { returns(T.nilable(::String)) } 95 | def config_yml; end 96 | 97 | def eql?(*args, &blk); end 98 | 99 | sig { returns(::Integer) } 100 | def hash; end 101 | 102 | sig { returns(::String) } 103 | def name; end 104 | 105 | sig { returns(T::Hash[T.untyped, T.untyped]) } 106 | def raw_hash; end 107 | 108 | sig { returns(::String) } 109 | def to_tag; end 110 | 111 | class << self 112 | sig { params(raw_hash: T::Hash[T.untyped, T.untyped]).returns(::CodeTeams::Team) } 113 | def from_hash(raw_hash); end 114 | 115 | sig { params(config_yml: ::String).returns(::CodeTeams::Team) } 116 | def from_yml(config_yml); end 117 | end 118 | end 119 | 120 | CodeTeams::UNKNOWN_TEAM_STRING = T.let(T.unsafe(nil), String) 121 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/colored2@3.1.2.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `colored2` gem. 5 | # Please instead update this file by running `bin/tapioca gem colored2`. 6 | 7 | module Colored2 8 | class << self 9 | def background_next!; end 10 | 11 | # @return [Boolean] 12 | def background_next?; end 13 | 14 | def decorate(a_class); end 15 | def disable!; end 16 | def enable!; end 17 | def foreground_next!; end 18 | 19 | # @private 20 | def included(from_class); end 21 | end 22 | end 23 | 24 | class Colored2::AsciiDecorator 25 | extend ::Forwardable 26 | 27 | # @return [AsciiDecorator] a new instance of AsciiDecorator 28 | def initialize(a_string); end 29 | 30 | # options[:start] = :color 31 | # options[:end] = :color | :no_color 32 | def decorate(options = T.unsafe(nil)); end 33 | 34 | def disable!(*args, &block); end 35 | def enable!(*args, &block); end 36 | 37 | # Returns the value of attribute my_class. 38 | def my_class; end 39 | 40 | # Sets the attribute my_class 41 | # 42 | # @param value the value to set the attribute my_class to. 43 | def my_class=(_arg0); end 44 | 45 | # Returns the value of attribute string. 46 | def string; end 47 | 48 | # Sets the attribute string 49 | # 50 | # @param value the value to set the attribute string to. 51 | def string=(_arg0); end 52 | 53 | def un_decorate; end 54 | 55 | private 56 | 57 | def no_color; end 58 | 59 | class << self 60 | # Returns the value of attribute __background_next. 61 | def __background_next; end 62 | 63 | # Sets the attribute __background_next 64 | # 65 | # @param value the value to set the attribute __background_next to. 66 | def __background_next=(_arg0); end 67 | 68 | # Returns the value of attribute __colors_disabled. 69 | def __colors_disabled; end 70 | 71 | # Sets the attribute __colors_disabled 72 | # 73 | # @param value the value to set the attribute __colors_disabled to. 74 | def __colors_disabled=(_arg0); end 75 | 76 | def background_next!; end 77 | 78 | # @return [Boolean] 79 | def background_next?; end 80 | 81 | def disable!; end 82 | def enable!; end 83 | 84 | # @return [Boolean] 85 | def enabled?; end 86 | 87 | def foreground_next!; end 88 | end 89 | end 90 | 91 | class Colored2::BackgroundColor < ::Colored2::TextColor 92 | def value; end 93 | end 94 | 95 | Colored2::COLORS = T.let(T.unsafe(nil), Hash) 96 | 97 | class Colored2::Code 98 | # @raise [ArgumentError] 99 | # @return [Code] a new instance of Code 100 | def initialize(name); end 101 | 102 | # Returns the value of attribute escape. 103 | def escape; end 104 | 105 | # Sets the attribute escape 106 | # 107 | # @param value the value to set the attribute escape to. 108 | def escape=(_arg0); end 109 | 110 | # Returns the value of attribute name. 111 | def name; end 112 | 113 | # Sets the attribute name 114 | # 115 | # @param value the value to set the attribute name to. 116 | def name=(_arg0); end 117 | 118 | def to_s; end 119 | def value(shift = T.unsafe(nil)); end 120 | end 121 | 122 | Colored2::EFFECTS = T.let(T.unsafe(nil), Hash) 123 | 124 | class Colored2::Effect < ::Colored2::Code 125 | def codes; end 126 | end 127 | 128 | class Colored2::TextColor < ::Colored2::Code 129 | def codes; end 130 | end 131 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/constant_resolver@0.2.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `constant_resolver` gem. 5 | # Please instead update this file by running `bin/tapioca gem constant_resolver`. 6 | 7 | class ConstantResolver 8 | def initialize(root_path:, load_paths:, inflector: T.unsafe(nil)); end 9 | 10 | def config; end 11 | def file_map; end 12 | def resolve(const_name, current_namespace_path: T.unsafe(nil)); end 13 | 14 | private 15 | 16 | def ambiguous_constant_message(const_name, paths); end 17 | def coerce_load_paths(load_paths); end 18 | def glob_path(path); end 19 | def resolve_constant(const_name, current_namespace_path, original_name: T.unsafe(nil)); end 20 | def resolve_traversing_namespace_path(const_name, current_namespace_path); end 21 | end 22 | 23 | class ConstantResolver::ConstantContext < ::Struct; end 24 | 25 | class ConstantResolver::DefaultInflector 26 | def camelize(string); end 27 | end 28 | 29 | class ConstantResolver::Error < ::StandardError; end 30 | ConstantResolver::VERSION = T.let(T.unsafe(nil), String) 31 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/danger-plugin-api@1.0.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `danger-plugin-api` gem. 5 | # Please instead update this file by running `bin/tapioca gem danger-plugin-api`. 6 | 7 | # THIS IS AN EMPTY RBI FILE. 8 | # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires 9 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/erubi@1.11.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `erubi` gem. 5 | # Please instead update this file by running `bin/tapioca gem erubi`. 6 | 7 | module Erubi 8 | class << self 9 | def h(value); end 10 | end 11 | end 12 | 13 | class Erubi::Engine 14 | # Initialize a new Erubi::Engine. Options: 15 | # +:bufval+ :: The value to use for the buffer variable, as a string (default '::String.new'). 16 | # +:bufvar+ :: The variable name to use for the buffer variable, as a string. 17 | # +:chain_appends+ :: Whether to chain << calls to the buffer variable. Offers better 18 | # performance, but can cause issues when the buffer variable is reassigned during 19 | # template rendering (default +false+). 20 | # +:ensure+ :: Wrap the template in a begin/ensure block restoring the previous value of bufvar. 21 | # +:escapefunc+ :: The function to use for escaping, as a string (default: '::Erubi.h'). 22 | # +:escape+ :: Whether to make <%= escape by default, and <%== not escape by default. 23 | # +:escape_html+ :: Same as +:escape+, with lower priority. 24 | # +:filename+ :: The filename for the template. 25 | # the resulting source code. Note this may cause problems if you are wrapping the resulting 26 | # source code in other code, because the magic comment only has an effect at the beginning of 27 | # the file, and having the magic comment later in the file can trigger warnings. 28 | # +:freeze_template_literals+ :: Whether to suffix all literal strings for template code with .freeze 29 | # (default: +true+ on Ruby 2.1+, +false+ on Ruby 2.0 and older). 30 | # Can be set to +false+ on Ruby 2.3+ when frozen string literals are enabled 31 | # in order to improve performance. 32 | # +:literal_prefix+ :: The prefix to output when using escaped tag delimiters (default '<%'). 33 | # +:literal_postfix+ :: The postfix to output when using escaped tag delimiters (default '%>'). 34 | # +:outvar+ :: Same as +:bufvar+, with lower priority. 35 | # +:postamble+ :: The postamble for the template, by default returns the resulting source code. 36 | # +:preamble+ :: The preamble for the template, by default initializes the buffer variable. 37 | # +:regexp+ :: The regexp to use for scanning. 38 | # +:src+ :: The initial value to use for the source code, an empty string by default. 39 | # +:trim+ :: Whether to trim leading and trailing whitespace, true by default. 40 | # 41 | # @return [Engine] a new instance of Engine 42 | def initialize(input, properties = T.unsafe(nil)); end 43 | 44 | # The variable name used for the buffer variable. 45 | def bufvar; end 46 | 47 | # The filename of the template, if one was given. 48 | def filename; end 49 | 50 | # The frozen ruby source code generated from the template, which can be evaled. 51 | def src; end 52 | 53 | private 54 | 55 | # Add ruby code to the template 56 | def add_code(code); end 57 | 58 | # Add the given ruby expression result to the template, 59 | # escaping it based on the indicator given and escape flag. 60 | def add_expression(indicator, code); end 61 | 62 | # Add the result of Ruby expression to the template 63 | def add_expression_result(code); end 64 | 65 | # Add the escaped result of Ruby expression to the template 66 | def add_expression_result_escaped(code); end 67 | 68 | # Add the given postamble to the src. Can be overridden in subclasses 69 | # to make additional changes to src that depend on the current state. 70 | def add_postamble(postamble); end 71 | 72 | # Add raw text to the template. Modifies argument if argument is mutable as a memory optimization. 73 | # Must be called with a string, cannot be called with nil (Rails's subclass depends on it). 74 | def add_text(text); end 75 | 76 | # Raise an exception, as the base engine class does not support handling other indicators. 77 | # 78 | # @raise [ArgumentError] 79 | def handle(indicator, code, tailch, rspace, lspace); end 80 | 81 | # Make sure that any current expression has been terminated. 82 | # The default is to terminate all expressions, but when 83 | # the chain_appends option is used, expressions may not be 84 | # terminated. 85 | def terminate_expression; end 86 | 87 | # Make sure the buffer variable is the target of the next append 88 | # before yielding to the block. Mark that the buffer is the target 89 | # of the next append after the block executes. 90 | # 91 | # This method should only be called if the block will result in 92 | # code where << will append to the bufvar. 93 | def with_buffer; end 94 | end 95 | 96 | # The default regular expression used for scanning. 97 | Erubi::Engine::DEFAULT_REGEXP = T.let(T.unsafe(nil), Regexp) 98 | 99 | Erubi::MATCH_METHOD = T.let(T.unsafe(nil), Symbol) 100 | Erubi::RANGE_FIRST = T.let(T.unsafe(nil), Integer) 101 | Erubi::RANGE_LAST = T.let(T.unsafe(nil), Integer) 102 | Erubi::VERSION = T.let(T.unsafe(nil), String) 103 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/faraday-em_synchrony@1.0.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `faraday-em_synchrony` gem. 5 | # Please instead update this file by running `bin/tapioca gem faraday-em_synchrony`. 6 | 7 | # This is the main namespace for Faraday. 8 | # 9 | # It provides methods to create {Connection} objects, and HTTP-related 10 | # methods to use directly. 11 | # 12 | # @example Helpful class methods for easy usage 13 | # Faraday.get "http://faraday.com" 14 | # @example Helpful class method `.new` to create {Connection} objects. 15 | # conn = Faraday.new "http://faraday.com" 16 | # conn.get '/' 17 | module Faraday 18 | class << self 19 | # @overload default_adapter 20 | # @overload default_adapter= 21 | def default_adapter; end 22 | 23 | # Documented elsewhere, see default_adapter reader 24 | def default_adapter=(adapter); end 25 | 26 | # @overload default_connection 27 | # @overload default_connection= 28 | def default_connection; end 29 | 30 | # Documented below, see default_connection 31 | def default_connection=(_arg0); end 32 | 33 | # Gets the default connection options used when calling {Faraday#new}. 34 | # 35 | # @return [Faraday::ConnectionOptions] 36 | def default_connection_options; end 37 | 38 | # Sets the default options used when calling {Faraday#new}. 39 | # 40 | # @param options [Hash, Faraday::ConnectionOptions] 41 | def default_connection_options=(options); end 42 | 43 | # Tells Faraday to ignore the environment proxy (http_proxy). 44 | # Defaults to `false`. 45 | # 46 | # @return [Boolean] 47 | def ignore_env_proxy; end 48 | 49 | # Tells Faraday to ignore the environment proxy (http_proxy). 50 | # Defaults to `false`. 51 | # 52 | # @return [Boolean] 53 | def ignore_env_proxy=(_arg0); end 54 | 55 | # Gets or sets the path that the Faraday libs are loaded from. 56 | # 57 | # @return [String] 58 | def lib_path; end 59 | 60 | # Gets or sets the path that the Faraday libs are loaded from. 61 | # 62 | # @return [String] 63 | def lib_path=(_arg0); end 64 | 65 | # Initializes a new {Connection}. 66 | # 67 | # @example With an URL argument 68 | # Faraday.new 'http://faraday.com' 69 | # # => Faraday::Connection to http://faraday.com 70 | # @example With everything in an options hash 71 | # Faraday.new url: 'http://faraday.com', 72 | # params: { page: 1 } 73 | # # => Faraday::Connection to http://faraday.com?page=1 74 | # @example With an URL argument and an options hash 75 | # Faraday.new 'http://faraday.com', params: { page: 1 } 76 | # # => Faraday::Connection to http://faraday.com?page=1 77 | # @option options 78 | # @option options 79 | # @option options 80 | # @option options 81 | # @option options 82 | # @option options 83 | # @param url [String, Hash] The optional String base URL to use as a prefix 84 | # for all requests. Can also be the options Hash. Any of these 85 | # values will be set on every request made, unless overridden 86 | # for a specific request. 87 | # @param options [Hash] 88 | # @return [Faraday::Connection] 89 | def new(url = T.unsafe(nil), options = T.unsafe(nil), &block); end 90 | 91 | # Internal: Requires internal Faraday libraries. 92 | # 93 | # @param libs [Array] one or more relative String names to Faraday classes. 94 | # @private 95 | # @return [void] 96 | def require_lib(*libs); end 97 | 98 | # Internal: Requires internal Faraday libraries. 99 | # 100 | # @param libs [Array] one or more relative String names to Faraday classes. 101 | # @private 102 | # @return [void] 103 | def require_libs(*libs); end 104 | 105 | # @return [Boolean] 106 | def respond_to_missing?(symbol, include_private = T.unsafe(nil)); end 107 | 108 | # The root path that Faraday is being loaded from. 109 | # 110 | # This is the root from where the libraries are auto-loaded. 111 | # 112 | # @return [String] 113 | def root_path; end 114 | 115 | # The root path that Faraday is being loaded from. 116 | # 117 | # This is the root from where the libraries are auto-loaded. 118 | # 119 | # @return [String] 120 | def root_path=(_arg0); end 121 | 122 | private 123 | 124 | # Internal: Proxies method calls on the Faraday constant to 125 | # .default_connection. 126 | def method_missing(name, *args, &block); end 127 | end 128 | end 129 | 130 | # Base class for all Faraday adapters. Adapters are 131 | # responsible for fulfilling a Faraday request. 132 | class Faraday::Adapter 133 | extend ::Faraday::MiddlewareRegistry 134 | extend ::Faraday::DependencyLoader 135 | extend ::Faraday::Adapter::Parallelism 136 | extend ::Faraday::AutoloadHelper 137 | 138 | # @return [Adapter] a new instance of Adapter 139 | def initialize(_app = T.unsafe(nil), opts = T.unsafe(nil), &block); end 140 | 141 | def call(env); end 142 | 143 | # Close any persistent connections. The adapter should still be usable 144 | # after calling close. 145 | def close; end 146 | 147 | # Yields or returns an adapter's configured connection. Depends on 148 | # #build_connection being defined on this adapter. 149 | # 150 | # @param env [Faraday::Env, Hash] The env object for a faraday request. 151 | # @return The return value of the given block, or the HTTP connection object 152 | # if no block is given. 153 | # @yield [conn] 154 | def connection(env); end 155 | 156 | private 157 | 158 | # Fetches either a read, write, or open timeout setting. Defaults to the 159 | # :timeout value if a more specific one is not given. 160 | # 161 | # @param type [Symbol] Describes which timeout setting to get: :read, 162 | # :write, or :open. 163 | # @param options [Hash] Hash containing Symbol keys like :timeout, 164 | # :read_timeout, :write_timeout, :open_timeout, or 165 | # :timeout 166 | # @return [Integer, nil] Timeout duration in seconds, or nil if no timeout 167 | # has been set. 168 | def request_timeout(type, options); end 169 | 170 | def save_response(env, status, body, headers = T.unsafe(nil), reason_phrase = T.unsafe(nil)); end 171 | end 172 | 173 | Faraday::Adapter::CONTENT_LENGTH = T.let(T.unsafe(nil), String) 174 | 175 | # EventMachine Synchrony adapter. 176 | class Faraday::Adapter::EMSynchrony < ::Faraday::Adapter 177 | include ::Faraday::Adapter::EMHttp::Options 178 | 179 | def call(env); end 180 | def create_request(env); end 181 | 182 | private 183 | 184 | def call_block(block); end 185 | def execute_parallel_request(env, request, http_method); end 186 | def execute_single_request(env, request, http_method); end 187 | 188 | class << self 189 | # @return [ParallelManager] 190 | def setup_parallel_manager(_options = T.unsafe(nil)); end 191 | end 192 | end 193 | 194 | Faraday::Adapter::TIMEOUT_KEYS = T.let(T.unsafe(nil), Hash) 195 | Faraday::CONTENT_TYPE = T.let(T.unsafe(nil), String) 196 | Faraday::CompositeReadIO = Faraday::Multipart::CompositeReadIO 197 | 198 | # Main Faraday::EmSynchrony module 199 | module Faraday::EmSynchrony; end 200 | 201 | Faraday::EmSynchrony::VERSION = T.let(T.unsafe(nil), String) 202 | Faraday::FilePart = Multipart::Post::UploadIO 203 | Faraday::METHODS_WITH_BODY = T.let(T.unsafe(nil), Array) 204 | Faraday::METHODS_WITH_QUERY = T.let(T.unsafe(nil), Array) 205 | Faraday::ParamPart = Faraday::Multipart::ParamPart 206 | Faraday::Parts = Multipart::Post::Parts 207 | Faraday::Timer = Timeout 208 | Faraday::UploadIO = Multipart::Post::UploadIO 209 | Faraday::VERSION = T.let(T.unsafe(nil), String) 210 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/faraday-excon@1.1.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `faraday-excon` gem. 5 | # Please instead update this file by running `bin/tapioca gem faraday-excon`. 6 | 7 | # This is the main namespace for Faraday. 8 | # 9 | # It provides methods to create {Connection} objects, and HTTP-related 10 | # methods to use directly. 11 | # 12 | # @example Helpful class methods for easy usage 13 | # Faraday.get "http://faraday.com" 14 | # @example Helpful class method `.new` to create {Connection} objects. 15 | # conn = Faraday.new "http://faraday.com" 16 | # conn.get '/' 17 | module Faraday 18 | class << self 19 | # @overload default_adapter 20 | # @overload default_adapter= 21 | def default_adapter; end 22 | 23 | # Documented elsewhere, see default_adapter reader 24 | def default_adapter=(adapter); end 25 | 26 | # @overload default_connection 27 | # @overload default_connection= 28 | def default_connection; end 29 | 30 | # Documented below, see default_connection 31 | def default_connection=(_arg0); end 32 | 33 | # Gets the default connection options used when calling {Faraday#new}. 34 | # 35 | # @return [Faraday::ConnectionOptions] 36 | def default_connection_options; end 37 | 38 | # Sets the default options used when calling {Faraday#new}. 39 | # 40 | # @param options [Hash, Faraday::ConnectionOptions] 41 | def default_connection_options=(options); end 42 | 43 | # Tells Faraday to ignore the environment proxy (http_proxy). 44 | # Defaults to `false`. 45 | # 46 | # @return [Boolean] 47 | def ignore_env_proxy; end 48 | 49 | # Tells Faraday to ignore the environment proxy (http_proxy). 50 | # Defaults to `false`. 51 | # 52 | # @return [Boolean] 53 | def ignore_env_proxy=(_arg0); end 54 | 55 | # Gets or sets the path that the Faraday libs are loaded from. 56 | # 57 | # @return [String] 58 | def lib_path; end 59 | 60 | # Gets or sets the path that the Faraday libs are loaded from. 61 | # 62 | # @return [String] 63 | def lib_path=(_arg0); end 64 | 65 | # Initializes a new {Connection}. 66 | # 67 | # @example With an URL argument 68 | # Faraday.new 'http://faraday.com' 69 | # # => Faraday::Connection to http://faraday.com 70 | # @example With everything in an options hash 71 | # Faraday.new url: 'http://faraday.com', 72 | # params: { page: 1 } 73 | # # => Faraday::Connection to http://faraday.com?page=1 74 | # @example With an URL argument and an options hash 75 | # Faraday.new 'http://faraday.com', params: { page: 1 } 76 | # # => Faraday::Connection to http://faraday.com?page=1 77 | # @option options 78 | # @option options 79 | # @option options 80 | # @option options 81 | # @option options 82 | # @option options 83 | # @param url [String, Hash] The optional String base URL to use as a prefix 84 | # for all requests. Can also be the options Hash. Any of these 85 | # values will be set on every request made, unless overridden 86 | # for a specific request. 87 | # @param options [Hash] 88 | # @return [Faraday::Connection] 89 | def new(url = T.unsafe(nil), options = T.unsafe(nil), &block); end 90 | 91 | # Internal: Requires internal Faraday libraries. 92 | # 93 | # @param libs [Array] one or more relative String names to Faraday classes. 94 | # @private 95 | # @return [void] 96 | def require_lib(*libs); end 97 | 98 | # Internal: Requires internal Faraday libraries. 99 | # 100 | # @param libs [Array] one or more relative String names to Faraday classes. 101 | # @private 102 | # @return [void] 103 | def require_libs(*libs); end 104 | 105 | # @return [Boolean] 106 | def respond_to_missing?(symbol, include_private = T.unsafe(nil)); end 107 | 108 | # The root path that Faraday is being loaded from. 109 | # 110 | # This is the root from where the libraries are auto-loaded. 111 | # 112 | # @return [String] 113 | def root_path; end 114 | 115 | # The root path that Faraday is being loaded from. 116 | # 117 | # This is the root from where the libraries are auto-loaded. 118 | # 119 | # @return [String] 120 | def root_path=(_arg0); end 121 | 122 | private 123 | 124 | # Internal: Proxies method calls on the Faraday constant to 125 | # .default_connection. 126 | def method_missing(name, *args, &block); end 127 | end 128 | end 129 | 130 | # Base class for all Faraday adapters. Adapters are 131 | # responsible for fulfilling a Faraday request. 132 | class Faraday::Adapter 133 | extend ::Faraday::MiddlewareRegistry 134 | extend ::Faraday::DependencyLoader 135 | extend ::Faraday::Adapter::Parallelism 136 | extend ::Faraday::AutoloadHelper 137 | 138 | # @return [Adapter] a new instance of Adapter 139 | def initialize(_app = T.unsafe(nil), opts = T.unsafe(nil), &block); end 140 | 141 | def call(env); end 142 | 143 | # Close any persistent connections. The adapter should still be usable 144 | # after calling close. 145 | def close; end 146 | 147 | # Yields or returns an adapter's configured connection. Depends on 148 | # #build_connection being defined on this adapter. 149 | # 150 | # @param env [Faraday::Env, Hash] The env object for a faraday request. 151 | # @return The return value of the given block, or the HTTP connection object 152 | # if no block is given. 153 | # @yield [conn] 154 | def connection(env); end 155 | 156 | private 157 | 158 | # Fetches either a read, write, or open timeout setting. Defaults to the 159 | # :timeout value if a more specific one is not given. 160 | # 161 | # @param type [Symbol] Describes which timeout setting to get: :read, 162 | # :write, or :open. 163 | # @param options [Hash] Hash containing Symbol keys like :timeout, 164 | # :read_timeout, :write_timeout, :open_timeout, or 165 | # :timeout 166 | # @return [Integer, nil] Timeout duration in seconds, or nil if no timeout 167 | # has been set. 168 | def request_timeout(type, options); end 169 | 170 | def save_response(env, status, body, headers = T.unsafe(nil), reason_phrase = T.unsafe(nil)); end 171 | end 172 | 173 | Faraday::Adapter::CONTENT_LENGTH = T.let(T.unsafe(nil), String) 174 | 175 | # Excon adapter. 176 | class Faraday::Adapter::Excon < ::Faraday::Adapter 177 | def build_connection(env); end 178 | def call(env); end 179 | 180 | # TODO: support streaming requests 181 | def read_body(env); end 182 | 183 | private 184 | 185 | def amend_opts_with_proxy_settings!(opts, req); end 186 | def amend_opts_with_ssl!(opts, ssl); end 187 | def amend_opts_with_timeouts!(opts, req); end 188 | 189 | # @return [Boolean] 190 | def needs_ssl_settings?(env); end 191 | 192 | def opts_from_env(env); end 193 | def proxy_settings_for_opts(proxy); end 194 | end 195 | 196 | Faraday::Adapter::Excon::OPTS_KEYS = T.let(T.unsafe(nil), Array) 197 | Faraday::Adapter::TIMEOUT_KEYS = T.let(T.unsafe(nil), Hash) 198 | Faraday::CONTENT_TYPE = T.let(T.unsafe(nil), String) 199 | Faraday::CompositeReadIO = Faraday::Multipart::CompositeReadIO 200 | 201 | # Main Faraday::Excon module 202 | module Faraday::Excon; end 203 | 204 | Faraday::Excon::VERSION = T.let(T.unsafe(nil), String) 205 | Faraday::FilePart = Multipart::Post::UploadIO 206 | Faraday::METHODS_WITH_BODY = T.let(T.unsafe(nil), Array) 207 | Faraday::METHODS_WITH_QUERY = T.let(T.unsafe(nil), Array) 208 | Faraday::ParamPart = Faraday::Multipart::ParamPart 209 | Faraday::Parts = Multipart::Post::Parts 210 | Faraday::Timer = Timeout 211 | Faraday::UploadIO = Multipart::Post::UploadIO 212 | Faraday::VERSION = T.let(T.unsafe(nil), String) 213 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/faraday-httpclient@1.0.1.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `faraday-httpclient` gem. 5 | # Please instead update this file by running `bin/tapioca gem faraday-httpclient`. 6 | 7 | # This is the main namespace for Faraday. 8 | # 9 | # It provides methods to create {Connection} objects, and HTTP-related 10 | # methods to use directly. 11 | # 12 | # @example Helpful class methods for easy usage 13 | # Faraday.get "http://faraday.com" 14 | # @example Helpful class method `.new` to create {Connection} objects. 15 | # conn = Faraday.new "http://faraday.com" 16 | # conn.get '/' 17 | module Faraday 18 | class << self 19 | # @overload default_adapter 20 | # @overload default_adapter= 21 | def default_adapter; end 22 | 23 | # Documented elsewhere, see default_adapter reader 24 | def default_adapter=(adapter); end 25 | 26 | # @overload default_connection 27 | # @overload default_connection= 28 | def default_connection; end 29 | 30 | # Documented below, see default_connection 31 | def default_connection=(_arg0); end 32 | 33 | # Gets the default connection options used when calling {Faraday#new}. 34 | # 35 | # @return [Faraday::ConnectionOptions] 36 | def default_connection_options; end 37 | 38 | # Sets the default options used when calling {Faraday#new}. 39 | # 40 | # @param options [Hash, Faraday::ConnectionOptions] 41 | def default_connection_options=(options); end 42 | 43 | # Tells Faraday to ignore the environment proxy (http_proxy). 44 | # Defaults to `false`. 45 | # 46 | # @return [Boolean] 47 | def ignore_env_proxy; end 48 | 49 | # Tells Faraday to ignore the environment proxy (http_proxy). 50 | # Defaults to `false`. 51 | # 52 | # @return [Boolean] 53 | def ignore_env_proxy=(_arg0); end 54 | 55 | # Gets or sets the path that the Faraday libs are loaded from. 56 | # 57 | # @return [String] 58 | def lib_path; end 59 | 60 | # Gets or sets the path that the Faraday libs are loaded from. 61 | # 62 | # @return [String] 63 | def lib_path=(_arg0); end 64 | 65 | # Initializes a new {Connection}. 66 | # 67 | # @example With an URL argument 68 | # Faraday.new 'http://faraday.com' 69 | # # => Faraday::Connection to http://faraday.com 70 | # @example With everything in an options hash 71 | # Faraday.new url: 'http://faraday.com', 72 | # params: { page: 1 } 73 | # # => Faraday::Connection to http://faraday.com?page=1 74 | # @example With an URL argument and an options hash 75 | # Faraday.new 'http://faraday.com', params: { page: 1 } 76 | # # => Faraday::Connection to http://faraday.com?page=1 77 | # @option options 78 | # @option options 79 | # @option options 80 | # @option options 81 | # @option options 82 | # @option options 83 | # @param url [String, Hash] The optional String base URL to use as a prefix 84 | # for all requests. Can also be the options Hash. Any of these 85 | # values will be set on every request made, unless overridden 86 | # for a specific request. 87 | # @param options [Hash] 88 | # @return [Faraday::Connection] 89 | def new(url = T.unsafe(nil), options = T.unsafe(nil), &block); end 90 | 91 | # Internal: Requires internal Faraday libraries. 92 | # 93 | # @param libs [Array] one or more relative String names to Faraday classes. 94 | # @private 95 | # @return [void] 96 | def require_lib(*libs); end 97 | 98 | # Internal: Requires internal Faraday libraries. 99 | # 100 | # @param libs [Array] one or more relative String names to Faraday classes. 101 | # @private 102 | # @return [void] 103 | def require_libs(*libs); end 104 | 105 | # @return [Boolean] 106 | def respond_to_missing?(symbol, include_private = T.unsafe(nil)); end 107 | 108 | # The root path that Faraday is being loaded from. 109 | # 110 | # This is the root from where the libraries are auto-loaded. 111 | # 112 | # @return [String] 113 | def root_path; end 114 | 115 | # The root path that Faraday is being loaded from. 116 | # 117 | # This is the root from where the libraries are auto-loaded. 118 | # 119 | # @return [String] 120 | def root_path=(_arg0); end 121 | 122 | private 123 | 124 | # Internal: Proxies method calls on the Faraday constant to 125 | # .default_connection. 126 | def method_missing(name, *args, &block); end 127 | end 128 | end 129 | 130 | # Base class for all Faraday adapters. Adapters are 131 | # responsible for fulfilling a Faraday request. 132 | class Faraday::Adapter 133 | extend ::Faraday::MiddlewareRegistry 134 | extend ::Faraday::DependencyLoader 135 | extend ::Faraday::Adapter::Parallelism 136 | extend ::Faraday::AutoloadHelper 137 | 138 | # @return [Adapter] a new instance of Adapter 139 | def initialize(_app = T.unsafe(nil), opts = T.unsafe(nil), &block); end 140 | 141 | def call(env); end 142 | 143 | # Close any persistent connections. The adapter should still be usable 144 | # after calling close. 145 | def close; end 146 | 147 | # Yields or returns an adapter's configured connection. Depends on 148 | # #build_connection being defined on this adapter. 149 | # 150 | # @param env [Faraday::Env, Hash] The env object for a faraday request. 151 | # @return The return value of the given block, or the HTTP connection object 152 | # if no block is given. 153 | # @yield [conn] 154 | def connection(env); end 155 | 156 | private 157 | 158 | # Fetches either a read, write, or open timeout setting. Defaults to the 159 | # :timeout value if a more specific one is not given. 160 | # 161 | # @param type [Symbol] Describes which timeout setting to get: :read, 162 | # :write, or :open. 163 | # @param options [Hash] Hash containing Symbol keys like :timeout, 164 | # :read_timeout, :write_timeout, :open_timeout, or 165 | # :timeout 166 | # @return [Integer, nil] Timeout duration in seconds, or nil if no timeout 167 | # has been set. 168 | def request_timeout(type, options); end 169 | 170 | def save_response(env, status, body, headers = T.unsafe(nil), reason_phrase = T.unsafe(nil)); end 171 | end 172 | 173 | Faraday::Adapter::CONTENT_LENGTH = T.let(T.unsafe(nil), String) 174 | 175 | # This class provides the main implementation for your adapter. 176 | # There are some key responsibilities that your adapter should satisfy: 177 | # * Initialize and store internally the client you chose (e.g. Net::HTTP) 178 | # * Process requests and save the response (see `#call`) 179 | class Faraday::Adapter::HTTPClient < ::Faraday::Adapter 180 | def build_connection(env); end 181 | def call(env); end 182 | def configure_client(client); end 183 | 184 | # Configure proxy URI and any user credentials. 185 | # 186 | # @param proxy [Hash] 187 | def configure_proxy(client, proxy); end 188 | 189 | # @param bind [Hash] 190 | def configure_socket(client, bind); end 191 | 192 | # @param ssl [Hash] 193 | def configure_ssl(client, ssl); end 194 | 195 | # @param req [Hash] 196 | def configure_timeouts(client, req); end 197 | 198 | # @param ssl [Hash] 199 | # @return [OpenSSL::X509::Store] 200 | def ssl_cert_store(ssl); end 201 | 202 | # @param ssl [Hash] 203 | def ssl_verify_mode(ssl); end 204 | end 205 | 206 | Faraday::Adapter::TIMEOUT_KEYS = T.let(T.unsafe(nil), Hash) 207 | Faraday::CONTENT_TYPE = T.let(T.unsafe(nil), String) 208 | Faraday::CompositeReadIO = Faraday::Multipart::CompositeReadIO 209 | Faraday::FilePart = Multipart::Post::UploadIO 210 | 211 | # Main Faraday::HTTPClient module 212 | module Faraday::HTTPClient; end 213 | 214 | Faraday::HTTPClient::VERSION = T.let(T.unsafe(nil), String) 215 | Faraday::METHODS_WITH_BODY = T.let(T.unsafe(nil), Array) 216 | Faraday::METHODS_WITH_QUERY = T.let(T.unsafe(nil), Array) 217 | Faraday::ParamPart = Faraday::Multipart::ParamPart 218 | Faraday::Parts = Multipart::Post::Parts 219 | Faraday::Timer = Timeout 220 | Faraday::UploadIO = Multipart::Post::UploadIO 221 | Faraday::VERSION = T.let(T.unsafe(nil), String) 222 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/faraday-net_http@1.0.1.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `faraday-net_http` gem. 5 | # Please instead update this file by running `bin/tapioca gem faraday-net_http`. 6 | 7 | # This is the main namespace for Faraday. 8 | # 9 | # It provides methods to create {Connection} objects, and HTTP-related 10 | # methods to use directly. 11 | # 12 | # @example Helpful class methods for easy usage 13 | # Faraday.get "http://faraday.com" 14 | # @example Helpful class method `.new` to create {Connection} objects. 15 | # conn = Faraday.new "http://faraday.com" 16 | # conn.get '/' 17 | module Faraday 18 | class << self 19 | # @overload default_adapter 20 | # @overload default_adapter= 21 | def default_adapter; end 22 | 23 | # Documented elsewhere, see default_adapter reader 24 | def default_adapter=(adapter); end 25 | 26 | # @overload default_connection 27 | # @overload default_connection= 28 | def default_connection; end 29 | 30 | # Documented below, see default_connection 31 | def default_connection=(_arg0); end 32 | 33 | # Gets the default connection options used when calling {Faraday#new}. 34 | # 35 | # @return [Faraday::ConnectionOptions] 36 | def default_connection_options; end 37 | 38 | # Sets the default options used when calling {Faraday#new}. 39 | # 40 | # @param options [Hash, Faraday::ConnectionOptions] 41 | def default_connection_options=(options); end 42 | 43 | # Tells Faraday to ignore the environment proxy (http_proxy). 44 | # Defaults to `false`. 45 | # 46 | # @return [Boolean] 47 | def ignore_env_proxy; end 48 | 49 | # Tells Faraday to ignore the environment proxy (http_proxy). 50 | # Defaults to `false`. 51 | # 52 | # @return [Boolean] 53 | def ignore_env_proxy=(_arg0); end 54 | 55 | # Gets or sets the path that the Faraday libs are loaded from. 56 | # 57 | # @return [String] 58 | def lib_path; end 59 | 60 | # Gets or sets the path that the Faraday libs are loaded from. 61 | # 62 | # @return [String] 63 | def lib_path=(_arg0); end 64 | 65 | # Initializes a new {Connection}. 66 | # 67 | # @example With an URL argument 68 | # Faraday.new 'http://faraday.com' 69 | # # => Faraday::Connection to http://faraday.com 70 | # @example With everything in an options hash 71 | # Faraday.new url: 'http://faraday.com', 72 | # params: { page: 1 } 73 | # # => Faraday::Connection to http://faraday.com?page=1 74 | # @example With an URL argument and an options hash 75 | # Faraday.new 'http://faraday.com', params: { page: 1 } 76 | # # => Faraday::Connection to http://faraday.com?page=1 77 | # @option options 78 | # @option options 79 | # @option options 80 | # @option options 81 | # @option options 82 | # @option options 83 | # @param url [String, Hash] The optional String base URL to use as a prefix 84 | # for all requests. Can also be the options Hash. Any of these 85 | # values will be set on every request made, unless overridden 86 | # for a specific request. 87 | # @param options [Hash] 88 | # @return [Faraday::Connection] 89 | def new(url = T.unsafe(nil), options = T.unsafe(nil), &block); end 90 | 91 | # Internal: Requires internal Faraday libraries. 92 | # 93 | # @param libs [Array] one or more relative String names to Faraday classes. 94 | # @private 95 | # @return [void] 96 | def require_lib(*libs); end 97 | 98 | # Internal: Requires internal Faraday libraries. 99 | # 100 | # @param libs [Array] one or more relative String names to Faraday classes. 101 | # @private 102 | # @return [void] 103 | def require_libs(*libs); end 104 | 105 | # @return [Boolean] 106 | def respond_to_missing?(symbol, include_private = T.unsafe(nil)); end 107 | 108 | # The root path that Faraday is being loaded from. 109 | # 110 | # This is the root from where the libraries are auto-loaded. 111 | # 112 | # @return [String] 113 | def root_path; end 114 | 115 | # The root path that Faraday is being loaded from. 116 | # 117 | # This is the root from where the libraries are auto-loaded. 118 | # 119 | # @return [String] 120 | def root_path=(_arg0); end 121 | 122 | private 123 | 124 | # Internal: Proxies method calls on the Faraday constant to 125 | # .default_connection. 126 | def method_missing(name, *args, &block); end 127 | end 128 | end 129 | 130 | # Base class for all Faraday adapters. Adapters are 131 | # responsible for fulfilling a Faraday request. 132 | class Faraday::Adapter 133 | extend ::Faraday::MiddlewareRegistry 134 | extend ::Faraday::DependencyLoader 135 | extend ::Faraday::Adapter::Parallelism 136 | extend ::Faraday::AutoloadHelper 137 | 138 | # @return [Adapter] a new instance of Adapter 139 | def initialize(_app = T.unsafe(nil), opts = T.unsafe(nil), &block); end 140 | 141 | def call(env); end 142 | 143 | # Close any persistent connections. The adapter should still be usable 144 | # after calling close. 145 | def close; end 146 | 147 | # Yields or returns an adapter's configured connection. Depends on 148 | # #build_connection being defined on this adapter. 149 | # 150 | # @param env [Faraday::Env, Hash] The env object for a faraday request. 151 | # @return The return value of the given block, or the HTTP connection object 152 | # if no block is given. 153 | # @yield [conn] 154 | def connection(env); end 155 | 156 | private 157 | 158 | # Fetches either a read, write, or open timeout setting. Defaults to the 159 | # :timeout value if a more specific one is not given. 160 | # 161 | # @param type [Symbol] Describes which timeout setting to get: :read, 162 | # :write, or :open. 163 | # @param options [Hash] Hash containing Symbol keys like :timeout, 164 | # :read_timeout, :write_timeout, :open_timeout, or 165 | # :timeout 166 | # @return [Integer, nil] Timeout duration in seconds, or nil if no timeout 167 | # has been set. 168 | def request_timeout(type, options); end 169 | 170 | def save_response(env, status, body, headers = T.unsafe(nil), reason_phrase = T.unsafe(nil)); end 171 | end 172 | 173 | Faraday::Adapter::CONTENT_LENGTH = T.let(T.unsafe(nil), String) 174 | 175 | class Faraday::Adapter::NetHttp < ::Faraday::Adapter 176 | # @return [NetHttp] a new instance of NetHttp 177 | def initialize(app = T.unsafe(nil), opts = T.unsafe(nil), &block); end 178 | 179 | def build_connection(env); end 180 | def call(env); end 181 | def net_http_connection(env); end 182 | 183 | private 184 | 185 | def configure_request(http, req); end 186 | def configure_ssl(http, ssl); end 187 | def create_request(env); end 188 | def perform_request(http, env); end 189 | def request_via_get_method(http, env, &block); end 190 | def request_via_request_method(http, env, &block); end 191 | def request_with_wrapped_block(http, env, &block); end 192 | def ssl_cert_store(ssl); end 193 | def ssl_verify_mode(ssl); end 194 | end 195 | 196 | Faraday::Adapter::NetHttp::NET_HTTP_EXCEPTIONS = T.let(T.unsafe(nil), Array) 197 | Faraday::Adapter::TIMEOUT_KEYS = T.let(T.unsafe(nil), Hash) 198 | Faraday::CONTENT_TYPE = T.let(T.unsafe(nil), String) 199 | Faraday::CompositeReadIO = Faraday::Multipart::CompositeReadIO 200 | 201 | # Aliases for Faraday v1, these are all deprecated and will be removed in v2 of this middleware 202 | Faraday::FilePart = Multipart::Post::UploadIO 203 | 204 | Faraday::METHODS_WITH_BODY = T.let(T.unsafe(nil), Array) 205 | Faraday::METHODS_WITH_QUERY = T.let(T.unsafe(nil), Array) 206 | module Faraday::NetHttp; end 207 | Faraday::NetHttp::VERSION = T.let(T.unsafe(nil), String) 208 | Faraday::ParamPart = Faraday::Multipart::ParamPart 209 | Faraday::Parts = Multipart::Post::Parts 210 | Faraday::Timer = Timeout 211 | 212 | # multipart-post v2.2.0 introduces a new class hierarchy for classes like Parts and UploadIO 213 | # For backwards compatibility, detect the gem version and use the right class 214 | Faraday::UploadIO = Multipart::Post::UploadIO 215 | 216 | Faraday::VERSION = T.let(T.unsafe(nil), String) 217 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/faraday-net_http_persistent@1.2.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `faraday-net_http_persistent` gem. 5 | # Please instead update this file by running `bin/tapioca gem faraday-net_http_persistent`. 6 | 7 | # This is the main namespace for Faraday. 8 | # 9 | # It provides methods to create {Connection} objects, and HTTP-related 10 | # methods to use directly. 11 | # 12 | # @example Helpful class methods for easy usage 13 | # Faraday.get "http://faraday.com" 14 | # @example Helpful class method `.new` to create {Connection} objects. 15 | # conn = Faraday.new "http://faraday.com" 16 | # conn.get '/' 17 | module Faraday 18 | class << self 19 | # @overload default_adapter 20 | # @overload default_adapter= 21 | def default_adapter; end 22 | 23 | # Documented elsewhere, see default_adapter reader 24 | def default_adapter=(adapter); end 25 | 26 | # @overload default_connection 27 | # @overload default_connection= 28 | def default_connection; end 29 | 30 | # Documented below, see default_connection 31 | def default_connection=(_arg0); end 32 | 33 | # Gets the default connection options used when calling {Faraday#new}. 34 | # 35 | # @return [Faraday::ConnectionOptions] 36 | def default_connection_options; end 37 | 38 | # Sets the default options used when calling {Faraday#new}. 39 | # 40 | # @param options [Hash, Faraday::ConnectionOptions] 41 | def default_connection_options=(options); end 42 | 43 | # Tells Faraday to ignore the environment proxy (http_proxy). 44 | # Defaults to `false`. 45 | # 46 | # @return [Boolean] 47 | def ignore_env_proxy; end 48 | 49 | # Tells Faraday to ignore the environment proxy (http_proxy). 50 | # Defaults to `false`. 51 | # 52 | # @return [Boolean] 53 | def ignore_env_proxy=(_arg0); end 54 | 55 | # Gets or sets the path that the Faraday libs are loaded from. 56 | # 57 | # @return [String] 58 | def lib_path; end 59 | 60 | # Gets or sets the path that the Faraday libs are loaded from. 61 | # 62 | # @return [String] 63 | def lib_path=(_arg0); end 64 | 65 | # Initializes a new {Connection}. 66 | # 67 | # @example With an URL argument 68 | # Faraday.new 'http://faraday.com' 69 | # # => Faraday::Connection to http://faraday.com 70 | # @example With everything in an options hash 71 | # Faraday.new url: 'http://faraday.com', 72 | # params: { page: 1 } 73 | # # => Faraday::Connection to http://faraday.com?page=1 74 | # @example With an URL argument and an options hash 75 | # Faraday.new 'http://faraday.com', params: { page: 1 } 76 | # # => Faraday::Connection to http://faraday.com?page=1 77 | # @option options 78 | # @option options 79 | # @option options 80 | # @option options 81 | # @option options 82 | # @option options 83 | # @param url [String, Hash] The optional String base URL to use as a prefix 84 | # for all requests. Can also be the options Hash. Any of these 85 | # values will be set on every request made, unless overridden 86 | # for a specific request. 87 | # @param options [Hash] 88 | # @return [Faraday::Connection] 89 | def new(url = T.unsafe(nil), options = T.unsafe(nil), &block); end 90 | 91 | # Internal: Requires internal Faraday libraries. 92 | # 93 | # @param libs [Array] one or more relative String names to Faraday classes. 94 | # @private 95 | # @return [void] 96 | def require_lib(*libs); end 97 | 98 | # Internal: Requires internal Faraday libraries. 99 | # 100 | # @param libs [Array] one or more relative String names to Faraday classes. 101 | # @private 102 | # @return [void] 103 | def require_libs(*libs); end 104 | 105 | # @return [Boolean] 106 | def respond_to_missing?(symbol, include_private = T.unsafe(nil)); end 107 | 108 | # The root path that Faraday is being loaded from. 109 | # 110 | # This is the root from where the libraries are auto-loaded. 111 | # 112 | # @return [String] 113 | def root_path; end 114 | 115 | # The root path that Faraday is being loaded from. 116 | # 117 | # This is the root from where the libraries are auto-loaded. 118 | # 119 | # @return [String] 120 | def root_path=(_arg0); end 121 | 122 | private 123 | 124 | # Internal: Proxies method calls on the Faraday constant to 125 | # .default_connection. 126 | def method_missing(name, *args, &block); end 127 | end 128 | end 129 | 130 | # Base class for all Faraday adapters. Adapters are 131 | # responsible for fulfilling a Faraday request. 132 | class Faraday::Adapter 133 | extend ::Faraday::MiddlewareRegistry 134 | extend ::Faraday::DependencyLoader 135 | extend ::Faraday::Adapter::Parallelism 136 | extend ::Faraday::AutoloadHelper 137 | 138 | # @return [Adapter] a new instance of Adapter 139 | def initialize(_app = T.unsafe(nil), opts = T.unsafe(nil), &block); end 140 | 141 | def call(env); end 142 | 143 | # Close any persistent connections. The adapter should still be usable 144 | # after calling close. 145 | def close; end 146 | 147 | # Yields or returns an adapter's configured connection. Depends on 148 | # #build_connection being defined on this adapter. 149 | # 150 | # @param env [Faraday::Env, Hash] The env object for a faraday request. 151 | # @return The return value of the given block, or the HTTP connection object 152 | # if no block is given. 153 | # @yield [conn] 154 | def connection(env); end 155 | 156 | private 157 | 158 | # Fetches either a read, write, or open timeout setting. Defaults to the 159 | # :timeout value if a more specific one is not given. 160 | # 161 | # @param type [Symbol] Describes which timeout setting to get: :read, 162 | # :write, or :open. 163 | # @param options [Hash] Hash containing Symbol keys like :timeout, 164 | # :read_timeout, :write_timeout, :open_timeout, or 165 | # :timeout 166 | # @return [Integer, nil] Timeout duration in seconds, or nil if no timeout 167 | # has been set. 168 | def request_timeout(type, options); end 169 | 170 | def save_response(env, status, body, headers = T.unsafe(nil), reason_phrase = T.unsafe(nil)); end 171 | end 172 | 173 | Faraday::Adapter::CONTENT_LENGTH = T.let(T.unsafe(nil), String) 174 | 175 | # Net::HTTP::Persistent adapter. 176 | class Faraday::Adapter::NetHttpPersistent < ::Faraday::Adapter::NetHttp 177 | private 178 | 179 | def configure_ssl(http, ssl); end 180 | def http_set(http, attr, value); end 181 | def net_http_connection(env); end 182 | def perform_request(http, env); end 183 | def proxy_uri(env); end 184 | end 185 | 186 | Faraday::Adapter::NetHttpPersistent::SSL_CONFIGURATIONS = T.let(T.unsafe(nil), Hash) 187 | Faraday::Adapter::TIMEOUT_KEYS = T.let(T.unsafe(nil), Hash) 188 | Faraday::CONTENT_TYPE = T.let(T.unsafe(nil), String) 189 | Faraday::CompositeReadIO = Faraday::Multipart::CompositeReadIO 190 | 191 | # Aliases for Faraday v1, these are all deprecated and will be removed in v2 of this middleware 192 | Faraday::FilePart = Multipart::Post::UploadIO 193 | 194 | Faraday::METHODS_WITH_BODY = T.let(T.unsafe(nil), Array) 195 | Faraday::METHODS_WITH_QUERY = T.let(T.unsafe(nil), Array) 196 | module Faraday::NetHttpPersistent; end 197 | Faraday::NetHttpPersistent::VERSION = T.let(T.unsafe(nil), String) 198 | Faraday::ParamPart = Faraday::Multipart::ParamPart 199 | Faraday::Parts = Multipart::Post::Parts 200 | Faraday::Timer = Timeout 201 | 202 | # multipart-post v2.2.0 introduces a new class hierarchy for classes like Parts and UploadIO 203 | # For backwards compatibility, detect the gem version and use the right class 204 | Faraday::UploadIO = Multipart::Post::UploadIO 205 | 206 | Faraday::VERSION = T.let(T.unsafe(nil), String) 207 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/faraday-patron@1.0.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `faraday-patron` gem. 5 | # Please instead update this file by running `bin/tapioca gem faraday-patron`. 6 | 7 | # This is the main namespace for Faraday. 8 | # 9 | # It provides methods to create {Connection} objects, and HTTP-related 10 | # methods to use directly. 11 | # 12 | # @example Helpful class methods for easy usage 13 | # Faraday.get "http://faraday.com" 14 | # @example Helpful class method `.new` to create {Connection} objects. 15 | # conn = Faraday.new "http://faraday.com" 16 | # conn.get '/' 17 | module Faraday 18 | class << self 19 | # @overload default_adapter 20 | # @overload default_adapter= 21 | def default_adapter; end 22 | 23 | # Documented elsewhere, see default_adapter reader 24 | def default_adapter=(adapter); end 25 | 26 | # @overload default_connection 27 | # @overload default_connection= 28 | def default_connection; end 29 | 30 | # Documented below, see default_connection 31 | def default_connection=(_arg0); end 32 | 33 | # Gets the default connection options used when calling {Faraday#new}. 34 | # 35 | # @return [Faraday::ConnectionOptions] 36 | def default_connection_options; end 37 | 38 | # Sets the default options used when calling {Faraday#new}. 39 | # 40 | # @param options [Hash, Faraday::ConnectionOptions] 41 | def default_connection_options=(options); end 42 | 43 | # Tells Faraday to ignore the environment proxy (http_proxy). 44 | # Defaults to `false`. 45 | # 46 | # @return [Boolean] 47 | def ignore_env_proxy; end 48 | 49 | # Tells Faraday to ignore the environment proxy (http_proxy). 50 | # Defaults to `false`. 51 | # 52 | # @return [Boolean] 53 | def ignore_env_proxy=(_arg0); end 54 | 55 | # Gets or sets the path that the Faraday libs are loaded from. 56 | # 57 | # @return [String] 58 | def lib_path; end 59 | 60 | # Gets or sets the path that the Faraday libs are loaded from. 61 | # 62 | # @return [String] 63 | def lib_path=(_arg0); end 64 | 65 | # Initializes a new {Connection}. 66 | # 67 | # @example With an URL argument 68 | # Faraday.new 'http://faraday.com' 69 | # # => Faraday::Connection to http://faraday.com 70 | # @example With everything in an options hash 71 | # Faraday.new url: 'http://faraday.com', 72 | # params: { page: 1 } 73 | # # => Faraday::Connection to http://faraday.com?page=1 74 | # @example With an URL argument and an options hash 75 | # Faraday.new 'http://faraday.com', params: { page: 1 } 76 | # # => Faraday::Connection to http://faraday.com?page=1 77 | # @option options 78 | # @option options 79 | # @option options 80 | # @option options 81 | # @option options 82 | # @option options 83 | # @param url [String, Hash] The optional String base URL to use as a prefix 84 | # for all requests. Can also be the options Hash. Any of these 85 | # values will be set on every request made, unless overridden 86 | # for a specific request. 87 | # @param options [Hash] 88 | # @return [Faraday::Connection] 89 | def new(url = T.unsafe(nil), options = T.unsafe(nil), &block); end 90 | 91 | # Internal: Requires internal Faraday libraries. 92 | # 93 | # @param libs [Array] one or more relative String names to Faraday classes. 94 | # @private 95 | # @return [void] 96 | def require_lib(*libs); end 97 | 98 | # Internal: Requires internal Faraday libraries. 99 | # 100 | # @param libs [Array] one or more relative String names to Faraday classes. 101 | # @private 102 | # @return [void] 103 | def require_libs(*libs); end 104 | 105 | # @return [Boolean] 106 | def respond_to_missing?(symbol, include_private = T.unsafe(nil)); end 107 | 108 | # The root path that Faraday is being loaded from. 109 | # 110 | # This is the root from where the libraries are auto-loaded. 111 | # 112 | # @return [String] 113 | def root_path; end 114 | 115 | # The root path that Faraday is being loaded from. 116 | # 117 | # This is the root from where the libraries are auto-loaded. 118 | # 119 | # @return [String] 120 | def root_path=(_arg0); end 121 | 122 | private 123 | 124 | # Internal: Proxies method calls on the Faraday constant to 125 | # .default_connection. 126 | def method_missing(name, *args, &block); end 127 | end 128 | end 129 | 130 | # Base class for all Faraday adapters. Adapters are 131 | # responsible for fulfilling a Faraday request. 132 | class Faraday::Adapter 133 | extend ::Faraday::MiddlewareRegistry 134 | extend ::Faraday::DependencyLoader 135 | extend ::Faraday::Adapter::Parallelism 136 | extend ::Faraday::AutoloadHelper 137 | 138 | # @return [Adapter] a new instance of Adapter 139 | def initialize(_app = T.unsafe(nil), opts = T.unsafe(nil), &block); end 140 | 141 | def call(env); end 142 | 143 | # Close any persistent connections. The adapter should still be usable 144 | # after calling close. 145 | def close; end 146 | 147 | # Yields or returns an adapter's configured connection. Depends on 148 | # #build_connection being defined on this adapter. 149 | # 150 | # @param env [Faraday::Env, Hash] The env object for a faraday request. 151 | # @return The return value of the given block, or the HTTP connection object 152 | # if no block is given. 153 | # @yield [conn] 154 | def connection(env); end 155 | 156 | private 157 | 158 | # Fetches either a read, write, or open timeout setting. Defaults to the 159 | # :timeout value if a more specific one is not given. 160 | # 161 | # @param type [Symbol] Describes which timeout setting to get: :read, 162 | # :write, or :open. 163 | # @param options [Hash] Hash containing Symbol keys like :timeout, 164 | # :read_timeout, :write_timeout, :open_timeout, or 165 | # :timeout 166 | # @return [Integer, nil] Timeout duration in seconds, or nil if no timeout 167 | # has been set. 168 | def request_timeout(type, options); end 169 | 170 | def save_response(env, status, body, headers = T.unsafe(nil), reason_phrase = T.unsafe(nil)); end 171 | end 172 | 173 | Faraday::Adapter::CONTENT_LENGTH = T.let(T.unsafe(nil), String) 174 | 175 | # Patron adapter 176 | class Faraday::Adapter::Patron < ::Faraday::Adapter 177 | def build_connection(env); end 178 | def call(env); end 179 | def configure_proxy(session, proxy); end 180 | def configure_ssl(session, ssl); end 181 | def configure_timeouts(session, req); end 182 | 183 | private 184 | 185 | # @return [Boolean] 186 | def connection_timed_out_message?(message); end 187 | end 188 | 189 | Faraday::Adapter::Patron::CURL_TIMEOUT_MESSAGES = T.let(T.unsafe(nil), Array) 190 | Faraday::Adapter::TIMEOUT_KEYS = T.let(T.unsafe(nil), Hash) 191 | Faraday::CONTENT_TYPE = T.let(T.unsafe(nil), String) 192 | Faraday::CompositeReadIO = Faraday::Multipart::CompositeReadIO 193 | 194 | # Aliases for Faraday v1, these are all deprecated and will be removed in v2 of this middleware 195 | Faraday::FilePart = Multipart::Post::UploadIO 196 | 197 | Faraday::METHODS_WITH_BODY = T.let(T.unsafe(nil), Array) 198 | Faraday::METHODS_WITH_QUERY = T.let(T.unsafe(nil), Array) 199 | Faraday::ParamPart = Faraday::Multipart::ParamPart 200 | Faraday::Parts = Multipart::Post::Parts 201 | 202 | # Main Faraday::Patron module 203 | module Faraday::Patron; end 204 | 205 | Faraday::Patron::VERSION = T.let(T.unsafe(nil), String) 206 | Faraday::Timer = Timeout 207 | 208 | # multipart-post v2.2.0 introduces a new class hierarchy for classes like Parts and UploadIO 209 | # For backwards compatibility, detect the gem version and use the right class 210 | Faraday::UploadIO = Multipart::Post::UploadIO 211 | 212 | Faraday::VERSION = T.let(T.unsafe(nil), String) 213 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/faraday-rack@1.0.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `faraday-rack` gem. 5 | # Please instead update this file by running `bin/tapioca gem faraday-rack`. 6 | 7 | # This is the main namespace for Faraday. 8 | # 9 | # It provides methods to create {Connection} objects, and HTTP-related 10 | # methods to use directly. 11 | # 12 | # @example Helpful class methods for easy usage 13 | # Faraday.get "http://faraday.com" 14 | # @example Helpful class method `.new` to create {Connection} objects. 15 | # conn = Faraday.new "http://faraday.com" 16 | # conn.get '/' 17 | module Faraday 18 | class << self 19 | # @overload default_adapter 20 | # @overload default_adapter= 21 | def default_adapter; end 22 | 23 | # Documented elsewhere, see default_adapter reader 24 | def default_adapter=(adapter); end 25 | 26 | # @overload default_connection 27 | # @overload default_connection= 28 | def default_connection; end 29 | 30 | # Documented below, see default_connection 31 | def default_connection=(_arg0); end 32 | 33 | # Gets the default connection options used when calling {Faraday#new}. 34 | # 35 | # @return [Faraday::ConnectionOptions] 36 | def default_connection_options; end 37 | 38 | # Sets the default options used when calling {Faraday#new}. 39 | # 40 | # @param options [Hash, Faraday::ConnectionOptions] 41 | def default_connection_options=(options); end 42 | 43 | # Tells Faraday to ignore the environment proxy (http_proxy). 44 | # Defaults to `false`. 45 | # 46 | # @return [Boolean] 47 | def ignore_env_proxy; end 48 | 49 | # Tells Faraday to ignore the environment proxy (http_proxy). 50 | # Defaults to `false`. 51 | # 52 | # @return [Boolean] 53 | def ignore_env_proxy=(_arg0); end 54 | 55 | # Gets or sets the path that the Faraday libs are loaded from. 56 | # 57 | # @return [String] 58 | def lib_path; end 59 | 60 | # Gets or sets the path that the Faraday libs are loaded from. 61 | # 62 | # @return [String] 63 | def lib_path=(_arg0); end 64 | 65 | # Initializes a new {Connection}. 66 | # 67 | # @example With an URL argument 68 | # Faraday.new 'http://faraday.com' 69 | # # => Faraday::Connection to http://faraday.com 70 | # @example With everything in an options hash 71 | # Faraday.new url: 'http://faraday.com', 72 | # params: { page: 1 } 73 | # # => Faraday::Connection to http://faraday.com?page=1 74 | # @example With an URL argument and an options hash 75 | # Faraday.new 'http://faraday.com', params: { page: 1 } 76 | # # => Faraday::Connection to http://faraday.com?page=1 77 | # @option options 78 | # @option options 79 | # @option options 80 | # @option options 81 | # @option options 82 | # @option options 83 | # @param url [String, Hash] The optional String base URL to use as a prefix 84 | # for all requests. Can also be the options Hash. Any of these 85 | # values will be set on every request made, unless overridden 86 | # for a specific request. 87 | # @param options [Hash] 88 | # @return [Faraday::Connection] 89 | def new(url = T.unsafe(nil), options = T.unsafe(nil), &block); end 90 | 91 | # Internal: Requires internal Faraday libraries. 92 | # 93 | # @param libs [Array] one or more relative String names to Faraday classes. 94 | # @private 95 | # @return [void] 96 | def require_lib(*libs); end 97 | 98 | # Internal: Requires internal Faraday libraries. 99 | # 100 | # @param libs [Array] one or more relative String names to Faraday classes. 101 | # @private 102 | # @return [void] 103 | def require_libs(*libs); end 104 | 105 | # @return [Boolean] 106 | def respond_to_missing?(symbol, include_private = T.unsafe(nil)); end 107 | 108 | # The root path that Faraday is being loaded from. 109 | # 110 | # This is the root from where the libraries are auto-loaded. 111 | # 112 | # @return [String] 113 | def root_path; end 114 | 115 | # The root path that Faraday is being loaded from. 116 | # 117 | # This is the root from where the libraries are auto-loaded. 118 | # 119 | # @return [String] 120 | def root_path=(_arg0); end 121 | 122 | private 123 | 124 | # Internal: Proxies method calls on the Faraday constant to 125 | # .default_connection. 126 | def method_missing(name, *args, &block); end 127 | end 128 | end 129 | 130 | # Base class for all Faraday adapters. Adapters are 131 | # responsible for fulfilling a Faraday request. 132 | class Faraday::Adapter 133 | extend ::Faraday::MiddlewareRegistry 134 | extend ::Faraday::DependencyLoader 135 | extend ::Faraday::Adapter::Parallelism 136 | extend ::Faraday::AutoloadHelper 137 | 138 | # @return [Adapter] a new instance of Adapter 139 | def initialize(_app = T.unsafe(nil), opts = T.unsafe(nil), &block); end 140 | 141 | def call(env); end 142 | 143 | # Close any persistent connections. The adapter should still be usable 144 | # after calling close. 145 | def close; end 146 | 147 | # Yields or returns an adapter's configured connection. Depends on 148 | # #build_connection being defined on this adapter. 149 | # 150 | # @param env [Faraday::Env, Hash] The env object for a faraday request. 151 | # @return The return value of the given block, or the HTTP connection object 152 | # if no block is given. 153 | # @yield [conn] 154 | def connection(env); end 155 | 156 | private 157 | 158 | # Fetches either a read, write, or open timeout setting. Defaults to the 159 | # :timeout value if a more specific one is not given. 160 | # 161 | # @param type [Symbol] Describes which timeout setting to get: :read, 162 | # :write, or :open. 163 | # @param options [Hash] Hash containing Symbol keys like :timeout, 164 | # :read_timeout, :write_timeout, :open_timeout, or 165 | # :timeout 166 | # @return [Integer, nil] Timeout duration in seconds, or nil if no timeout 167 | # has been set. 168 | def request_timeout(type, options); end 169 | 170 | def save_response(env, status, body, headers = T.unsafe(nil), reason_phrase = T.unsafe(nil)); end 171 | end 172 | 173 | Faraday::Adapter::CONTENT_LENGTH = T.let(T.unsafe(nil), String) 174 | 175 | # Sends requests to a Rack app. 176 | # 177 | # @example 178 | # 179 | # class MyRackApp 180 | # def call(env) 181 | # [200, {'Content-Type' => 'text/html'}, ["hello world"]] 182 | # end 183 | # end 184 | # 185 | # Faraday.new do |conn| 186 | # conn.adapter :rack, MyRackApp.new 187 | # end 188 | class Faraday::Adapter::Rack < ::Faraday::Adapter 189 | # @return [Rack] a new instance of Rack 190 | def initialize(faraday_app, rack_app); end 191 | 192 | def call(env); end 193 | 194 | private 195 | 196 | def build_rack_env(env); end 197 | def execute_request(env, rack_env); end 198 | end 199 | 200 | # not prefixed with "HTTP_" 201 | Faraday::Adapter::Rack::SPECIAL_HEADERS = T.let(T.unsafe(nil), Array) 202 | 203 | Faraday::Adapter::TIMEOUT_KEYS = T.let(T.unsafe(nil), Hash) 204 | Faraday::CONTENT_TYPE = T.let(T.unsafe(nil), String) 205 | Faraday::CompositeReadIO = Faraday::Multipart::CompositeReadIO 206 | 207 | # Aliases for Faraday v1, these are all deprecated and will be removed in v2 of this middleware 208 | Faraday::FilePart = Multipart::Post::UploadIO 209 | 210 | Faraday::METHODS_WITH_BODY = T.let(T.unsafe(nil), Array) 211 | Faraday::METHODS_WITH_QUERY = T.let(T.unsafe(nil), Array) 212 | Faraday::ParamPart = Faraday::Multipart::ParamPart 213 | Faraday::Parts = Multipart::Post::Parts 214 | 215 | # Main Faraday::Rack module 216 | module Faraday::Rack; end 217 | 218 | Faraday::Rack::VERSION = T.let(T.unsafe(nil), String) 219 | Faraday::Timer = Timeout 220 | 221 | # multipart-post v2.2.0 introduces a new class hierarchy for classes like Parts and UploadIO 222 | # For backwards compatibility, detect the gem version and use the right class 223 | Faraday::UploadIO = Multipart::Post::UploadIO 224 | 225 | Faraday::VERSION = T.let(T.unsafe(nil), String) 226 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/faraday-retry@1.0.3.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `faraday-retry` gem. 5 | # Please instead update this file by running `bin/tapioca gem faraday-retry`. 6 | 7 | # Faraday namespace. 8 | module Faraday 9 | class << self 10 | # @overload default_adapter 11 | # @overload default_adapter= 12 | def default_adapter; end 13 | 14 | # Documented elsewhere, see default_adapter reader 15 | def default_adapter=(adapter); end 16 | 17 | # @overload default_connection 18 | # @overload default_connection= 19 | def default_connection; end 20 | 21 | # Documented below, see default_connection 22 | def default_connection=(_arg0); end 23 | 24 | # Gets the default connection options used when calling {Faraday#new}. 25 | # 26 | # @return [Faraday::ConnectionOptions] 27 | def default_connection_options; end 28 | 29 | # Sets the default options used when calling {Faraday#new}. 30 | # 31 | # @param options [Hash, Faraday::ConnectionOptions] 32 | def default_connection_options=(options); end 33 | 34 | # Tells Faraday to ignore the environment proxy (http_proxy). 35 | # Defaults to `false`. 36 | # 37 | # @return [Boolean] 38 | def ignore_env_proxy; end 39 | 40 | # Tells Faraday to ignore the environment proxy (http_proxy). 41 | # Defaults to `false`. 42 | # 43 | # @return [Boolean] 44 | def ignore_env_proxy=(_arg0); end 45 | 46 | # Gets or sets the path that the Faraday libs are loaded from. 47 | # 48 | # @return [String] 49 | def lib_path; end 50 | 51 | # Gets or sets the path that the Faraday libs are loaded from. 52 | # 53 | # @return [String] 54 | def lib_path=(_arg0); end 55 | 56 | # Initializes a new {Connection}. 57 | # 58 | # @example With an URL argument 59 | # Faraday.new 'http://faraday.com' 60 | # # => Faraday::Connection to http://faraday.com 61 | # @example With everything in an options hash 62 | # Faraday.new url: 'http://faraday.com', 63 | # params: { page: 1 } 64 | # # => Faraday::Connection to http://faraday.com?page=1 65 | # @example With an URL argument and an options hash 66 | # Faraday.new 'http://faraday.com', params: { page: 1 } 67 | # # => Faraday::Connection to http://faraday.com?page=1 68 | # @option options 69 | # @option options 70 | # @option options 71 | # @option options 72 | # @option options 73 | # @option options 74 | # @param url [String, Hash] The optional String base URL to use as a prefix 75 | # for all requests. Can also be the options Hash. Any of these 76 | # values will be set on every request made, unless overridden 77 | # for a specific request. 78 | # @param options [Hash] 79 | # @return [Faraday::Connection] 80 | def new(url = T.unsafe(nil), options = T.unsafe(nil), &block); end 81 | 82 | # Internal: Requires internal Faraday libraries. 83 | # 84 | # @param libs [Array] one or more relative String names to Faraday classes. 85 | # @private 86 | # @return [void] 87 | def require_lib(*libs); end 88 | 89 | # Internal: Requires internal Faraday libraries. 90 | # 91 | # @param libs [Array] one or more relative String names to Faraday classes. 92 | # @private 93 | # @return [void] 94 | def require_libs(*libs); end 95 | 96 | # @return [Boolean] 97 | def respond_to_missing?(symbol, include_private = T.unsafe(nil)); end 98 | 99 | # The root path that Faraday is being loaded from. 100 | # 101 | # This is the root from where the libraries are auto-loaded. 102 | # 103 | # @return [String] 104 | def root_path; end 105 | 106 | # The root path that Faraday is being loaded from. 107 | # 108 | # This is the root from where the libraries are auto-loaded. 109 | # 110 | # @return [String] 111 | def root_path=(_arg0); end 112 | 113 | private 114 | 115 | # Internal: Proxies method calls on the Faraday constant to 116 | # .default_connection. 117 | def method_missing(name, *args, &block); end 118 | end 119 | end 120 | 121 | Faraday::CONTENT_TYPE = T.let(T.unsafe(nil), String) 122 | Faraday::CompositeReadIO = Faraday::Multipart::CompositeReadIO 123 | 124 | # Aliases for Faraday v1, these are all deprecated and will be removed in v2 of this middleware 125 | Faraday::FilePart = Multipart::Post::UploadIO 126 | 127 | Faraday::METHODS_WITH_BODY = T.let(T.unsafe(nil), Array) 128 | Faraday::METHODS_WITH_QUERY = T.let(T.unsafe(nil), Array) 129 | Faraday::ParamPart = Faraday::Multipart::ParamPart 130 | Faraday::Parts = Multipart::Post::Parts 131 | 132 | # Exception used to control the Retry middleware. 133 | class Faraday::RetriableResponse < ::Faraday::Error; end 134 | 135 | # Middleware main module. 136 | module Faraday::Retry; end 137 | 138 | # This class provides the main implementation for your middleware. 139 | # Your middleware can implement any of the following methods: 140 | # * on_request - called when the request is being prepared 141 | # * on_complete - called when the response is being processed 142 | # 143 | # Optionally, you can also override the following methods from Faraday::Middleware 144 | # * initialize(app, options = {}) - the initializer method 145 | # * call(env) - the main middleware invocation method. 146 | # This already calls on_request and on_complete, so you normally don't need to override it. 147 | # You may need to in case you need to "wrap" the request or need more control 148 | # (see "retry" middleware: https://github.com/lostisland/faraday/blob/main/lib/faraday/request/retry.rb#L142). 149 | # IMPORTANT: Remember to call `@app.call(env)` or `super` to not interrupt the middleware chain! 150 | class Faraday::Retry::Middleware < ::Faraday::Middleware 151 | # @option options 152 | # @option options 153 | # @option options 154 | # @option options 155 | # @option options 156 | # @option options 157 | # @option options 158 | # @option options 159 | # @option options 160 | # @option options 161 | # @param app [#call] 162 | # @param options [Hash] 163 | # @return [Middleware] a new instance of Middleware 164 | def initialize(app, options = T.unsafe(nil)); end 165 | 166 | # An exception matcher for the rescue clause can usually be any object 167 | # that responds to `===`, but for Ruby 1.8 it has to be a Class or Module. 168 | # 169 | # @api private 170 | # @param exceptions [Array] 171 | # @return [Module] an exception matcher 172 | def build_exception_matcher(exceptions); end 173 | 174 | def calculate_sleep_amount(retries, env); end 175 | 176 | # @param env [Faraday::Env] 177 | def call(env); end 178 | 179 | private 180 | 181 | # MDN spec for Retry-After header: 182 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After 183 | def calculate_retry_after(env); end 184 | 185 | def calculate_retry_interval(retries); end 186 | 187 | # @return [Boolean] 188 | def retry_request?(env, exception); end 189 | 190 | def rewind_files(body); end 191 | end 192 | 193 | Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS = T.let(T.unsafe(nil), Array) 194 | Faraday::Retry::Middleware::IDEMPOTENT_METHODS = T.let(T.unsafe(nil), Array) 195 | 196 | # Options contains the configurable parameters for the Retry middleware. 197 | class Faraday::Retry::Middleware::Options < ::Faraday::Options 198 | def backoff_factor; end 199 | def exceptions; end 200 | def interval; end 201 | def interval_randomness; end 202 | def max; end 203 | def max_interval; end 204 | def methods; end 205 | def retry_block; end 206 | def retry_if; end 207 | def retry_statuses; end 208 | 209 | class << self 210 | def from(value); end 211 | end 212 | end 213 | 214 | Faraday::Retry::Middleware::Options::DEFAULT_CHECK = T.let(T.unsafe(nil), Proc) 215 | Faraday::Retry::VERSION = T.let(T.unsafe(nil), String) 216 | Faraday::Timer = Timeout 217 | 218 | # multipart-post v2.2.0 introduces a new class hierarchy for classes like Parts and UploadIO 219 | # For backwards compatibility, detect the gem version and use the right class 220 | Faraday::UploadIO = Multipart::Post::UploadIO 221 | 222 | Faraday::VERSION = T.let(T.unsafe(nil), String) 223 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `kramdown-parser-gfm` gem. 5 | # Please instead update this file by running `bin/tapioca gem kramdown-parser-gfm`. 6 | 7 | # THIS IS AN EMPTY RBI FILE. 8 | # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires 9 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/method_source@1.0.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `method_source` gem. 5 | # Please instead update this file by running `bin/tapioca gem method_source`. 6 | 7 | module MethodSource 8 | extend ::MethodSource::CodeHelpers 9 | 10 | class << self 11 | # Helper method responsible for opening source file and buffering up 12 | # the comments for a specified method. Defined here to avoid polluting 13 | # `Method` class. 14 | # 15 | # @param source_location [Array] The array returned by Method#source_location 16 | # @param method_name [String] 17 | # @raise [SourceNotFoundError] 18 | # @return [String] The comments up to the point of the method. 19 | def comment_helper(source_location, name = T.unsafe(nil)); end 20 | 21 | # @deprecated — use MethodSource::CodeHelpers#expression_at 22 | def extract_code(source_location); end 23 | 24 | # Load a memoized copy of the lines in a file. 25 | # 26 | # @param file_name [String] 27 | # @param method_name [String] 28 | # @raise [SourceNotFoundError] 29 | # @return [Array] the contents of the file 30 | def lines_for(file_name, name = T.unsafe(nil)); end 31 | 32 | # Helper method responsible for extracting method body. 33 | # Defined here to avoid polluting `Method` class. 34 | # 35 | # @param source_location [Array] The array returned by Method#source_location 36 | # @param method_name [String] 37 | # @return [String] The method body 38 | def source_helper(source_location, name = T.unsafe(nil)); end 39 | 40 | # @deprecated — use MethodSource::CodeHelpers#complete_expression? 41 | # @return [Boolean] 42 | def valid_expression?(str); end 43 | end 44 | end 45 | 46 | module MethodSource::CodeHelpers 47 | # Retrieve the comment describing the expression on the given line of the given file. 48 | # 49 | # This is useful to get module or method documentation. 50 | # 51 | # @param file [Array, File, String] The file to parse, either as a File or as 52 | # a String or an Array of lines. 53 | # @param line_number [Integer] The line number at which to look. 54 | # NOTE: The first line in a file is line 1! 55 | # @return [String] The comment 56 | def comment_describing(file, line_number); end 57 | 58 | # Determine if a string of code is a complete Ruby expression. 59 | # 60 | # @example 61 | # complete_expression?("class Hello") #=> false 62 | # complete_expression?("class Hello; end") #=> true 63 | # complete_expression?("class 123") #=> SyntaxError: unexpected tINTEGER 64 | # @param code [String] The code to validate. 65 | # @raise [SyntaxError] Any SyntaxError that does not represent incompleteness. 66 | # @return [Boolean] Whether or not the code is a complete Ruby expression. 67 | def complete_expression?(str); end 68 | 69 | # Retrieve the first expression starting on the given line of the given file. 70 | # 71 | # This is useful to get module or method source code. 72 | # 73 | # line 1! 74 | # 75 | # @option options 76 | # @option options 77 | # @param file [Array, File, String] The file to parse, either as a File or as 78 | # @param line_number [Integer] The line number at which to look. 79 | # NOTE: The first line in a file is 80 | # @param options [Hash] The optional configuration parameters. 81 | # @raise [SyntaxError] If the first complete expression can't be identified 82 | # @return [String] The first complete expression 83 | def expression_at(file, line_number, options = T.unsafe(nil)); end 84 | 85 | private 86 | 87 | # Get the first expression from the input. 88 | # 89 | # @param lines [Array] 90 | # @param consume [Integer] A number of lines to automatically 91 | # consume (add to the expression buffer) without checking for validity. 92 | # @raise [SyntaxError] 93 | # @return [String] a valid ruby expression 94 | # @yield a clean-up function to run before checking for complete_expression 95 | def extract_first_expression(lines, consume = T.unsafe(nil), &block); end 96 | 97 | # Get the last comment from the input. 98 | # 99 | # @param lines [Array] 100 | # @return [String] 101 | def extract_last_comment(lines); end 102 | end 103 | 104 | # An exception matcher that matches only subsets of SyntaxErrors that can be 105 | # fixed by adding more input to the buffer. 106 | module MethodSource::CodeHelpers::IncompleteExpression 107 | class << self 108 | def ===(ex); end 109 | 110 | # @return [Boolean] 111 | def rbx?; end 112 | end 113 | end 114 | 115 | MethodSource::CodeHelpers::IncompleteExpression::GENERIC_REGEXPS = T.let(T.unsafe(nil), Array) 116 | MethodSource::CodeHelpers::IncompleteExpression::RBX_ONLY_REGEXPS = T.let(T.unsafe(nil), Array) 117 | 118 | # This module is to be included by `Method` and `UnboundMethod` and 119 | # provides the `#source` functionality 120 | module MethodSource::MethodExtensions 121 | # Return the comments associated with the method as a string. 122 | # 123 | # @example 124 | # Set.instance_method(:clear).comment.display 125 | # => 126 | # # Removes all elements and returns self. 127 | # @raise SourceNotFoundException 128 | # @return [String] The method's comments as a string 129 | def comment; end 130 | 131 | # Return the sourcecode for the method as a string 132 | # 133 | # @example 134 | # Set.instance_method(:clear).source.display 135 | # => 136 | # def clear 137 | # @hash.clear 138 | # self 139 | # end 140 | # @raise SourceNotFoundException 141 | # @return [String] The method sourcecode as a string 142 | def source; end 143 | 144 | class << self 145 | # We use the included hook to patch Method#source on rubinius. 146 | # We need to use the included hook as Rubinius defines a `source` 147 | # on Method so including a module will have no effect (as it's 148 | # higher up the MRO). 149 | # 150 | # @param klass [Class] The class that includes the module. 151 | def included(klass); end 152 | end 153 | end 154 | 155 | module MethodSource::ReeSourceLocation 156 | # Ruby enterprise edition provides all the information that's 157 | # needed, in a slightly different way. 158 | def source_location; end 159 | end 160 | 161 | module MethodSource::SourceLocation; end 162 | 163 | module MethodSource::SourceLocation::MethodExtensions 164 | # Return the source location of a method for Ruby 1.8. 165 | # 166 | # @return [Array] A two element array. First element is the 167 | # file, second element is the line in the file where the 168 | # method definition is found. 169 | def source_location; end 170 | 171 | private 172 | 173 | def trace_func(event, file, line, id, binding, classname); end 174 | end 175 | 176 | module MethodSource::SourceLocation::ProcExtensions 177 | # Return the source location for a Proc (in implementations 178 | # without Proc#source_location) 179 | # 180 | # @return [Array] A two element array. First element is the 181 | # file, second element is the line in the file where the 182 | # proc definition is found. 183 | def source_location; end 184 | end 185 | 186 | module MethodSource::SourceLocation::UnboundMethodExtensions 187 | # Return the source location of an instance method for Ruby 1.8. 188 | # 189 | # @return [Array] A two element array. First element is the 190 | # file, second element is the line in the file where the 191 | # method definition is found. 192 | def source_location; end 193 | end 194 | 195 | # An Exception to mark errors that were raised trying to find the source from 196 | # a given source_location. 197 | class MethodSource::SourceNotFoundError < ::StandardError; end 198 | 199 | MethodSource::VERSION = T.let(T.unsafe(nil), String) 200 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/multipart-post@2.2.3.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `multipart-post` gem. 5 | # Please instead update this file by running `bin/tapioca gem multipart-post`. 6 | 7 | CompositeIO = Multipart::Post::CompositeReadIO 8 | module Multipart; end 9 | module Multipart::Post; end 10 | 11 | # Concatenate together multiple IO objects into a single, composite IO object 12 | # for purposes of reading as a single stream. 13 | # 14 | # @example 15 | # crio = CompositeReadIO.new(StringIO.new('one'), 16 | # StringIO.new('two'), 17 | # StringIO.new('three')) 18 | # puts crio.read # => "onetwothree" 19 | class Multipart::Post::CompositeReadIO 20 | # Create a new composite-read IO from the arguments, all of which should 21 | # respond to #read in a manner consistent with IO. 22 | # 23 | # @return [CompositeReadIO] a new instance of CompositeReadIO 24 | def initialize(*ios); end 25 | 26 | # Read from IOs in order until `length` bytes have been received. 27 | def read(length = T.unsafe(nil), outbuf = T.unsafe(nil)); end 28 | 29 | def rewind; end 30 | 31 | private 32 | 33 | def advance_io; end 34 | def current_io; end 35 | end 36 | 37 | module Multipart::Post::Multipartable 38 | def initialize(path, params, headers = T.unsafe(nil), boundary = T.unsafe(nil)); end 39 | 40 | # Returns the value of attribute boundary. 41 | def boundary; end 42 | 43 | private 44 | 45 | def symbolize_keys(hash); end 46 | 47 | class << self 48 | def secure_boundary; end 49 | end 50 | end 51 | 52 | module Multipart::Post::Parts; end 53 | 54 | # Represents the epilogue or closing boundary. 55 | class Multipart::Post::Parts::EpiloguePart 56 | include ::Multipart::Post::Parts::Part 57 | 58 | # @return [EpiloguePart] a new instance of EpiloguePart 59 | def initialize(boundary); end 60 | end 61 | 62 | # Represents a part to be filled from file IO. 63 | class Multipart::Post::Parts::FilePart 64 | include ::Multipart::Post::Parts::Part 65 | 66 | # @param boundary [String] 67 | # @param name [#to_s] 68 | # @param io [IO] 69 | # @param headers [Hash] 70 | # @return [FilePart] a new instance of FilePart 71 | def initialize(boundary, name, io, headers = T.unsafe(nil)); end 72 | 73 | # @param boundary [String] 74 | # @param name [#to_s] 75 | # @param filename [String] 76 | # @param type [String] 77 | # @param content_len [Integer] 78 | # @param opts [Hash] 79 | def build_head(boundary, name, filename, type, content_len, opts = T.unsafe(nil)); end 80 | 81 | # Returns the value of attribute length. 82 | def length; end 83 | end 84 | 85 | # Represents a parametric part to be filled with given value. 86 | class Multipart::Post::Parts::ParamPart 87 | include ::Multipart::Post::Parts::Part 88 | 89 | # @param boundary [String] 90 | # @param name [#to_s] 91 | # @param value [String] 92 | # @param headers [Hash] Content-Type and Content-ID are used, if present. 93 | # @return [ParamPart] a new instance of ParamPart 94 | def initialize(boundary, name, value, headers = T.unsafe(nil)); end 95 | 96 | # @param boundary [String] 97 | # @param name [#to_s] 98 | # @param value [String] 99 | # @param headers [Hash] Content-Type is used, if present. 100 | def build_part(boundary, name, value, headers = T.unsafe(nil)); end 101 | 102 | def length; end 103 | end 104 | 105 | module Multipart::Post::Parts::Part 106 | def length; end 107 | def to_io; end 108 | 109 | class << self 110 | # @return [Boolean] 111 | def file?(value); end 112 | 113 | def new(boundary, name, value, headers = T.unsafe(nil)); end 114 | end 115 | end 116 | 117 | # Convenience methods for dealing with files and IO that are to be uploaded. 118 | class Multipart::Post::UploadIO 119 | # Create an upload IO suitable for including in the params hash of a 120 | # Net::HTTP::Post::Multipart. 121 | # 122 | # Can take two forms. The first accepts a filename and content type, and 123 | # opens the file for reading (to be closed by finalizer). 124 | # 125 | # The second accepts an already-open IO, but also requires a third argument, 126 | # the filename from which it was opened (particularly useful/recommended if 127 | # uploading directly from a form in a framework, which often save the file to 128 | # an arbitrarily named RackMultipart file in /tmp). 129 | # 130 | # @example 131 | # UploadIO.new("file.txt", "text/plain") 132 | # UploadIO.new(file_io, "text/plain", "file.txt") 133 | # @return [UploadIO] a new instance of UploadIO 134 | def initialize(filename_or_io, content_type, filename = T.unsafe(nil), opts = T.unsafe(nil)); end 135 | 136 | # Returns the value of attribute content_type. 137 | def content_type; end 138 | 139 | # Returns the value of attribute io. 140 | def io; end 141 | 142 | # Returns the value of attribute local_path. 143 | def local_path; end 144 | 145 | def method_missing(*args); end 146 | 147 | # Returns the value of attribute opts. 148 | def opts; end 149 | 150 | # Returns the value of attribute original_filename. 151 | def original_filename; end 152 | 153 | # @return [Boolean] 154 | def respond_to?(meth, include_all = T.unsafe(nil)); end 155 | 156 | class << self 157 | # @raise [ArgumentError] 158 | def convert!(io, content_type, original_filename, local_path); end 159 | end 160 | end 161 | 162 | Multipart::Post::VERSION = T.let(T.unsafe(nil), String) 163 | Multipartable = Multipart::Post::Multipartable 164 | Parts = Multipart::Post::Parts 165 | UploadIO = Multipart::Post::UploadIO 166 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/no_proxy_fix@0.1.2.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `no_proxy_fix` gem. 5 | # Please instead update this file by running `bin/tapioca gem no_proxy_fix`. 6 | 7 | module NoProxyFix; end 8 | NoProxyFix::VERSION = T.let(T.unsafe(nil), String) 9 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/open4@1.3.4.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `open4` gem. 5 | # Please instead update this file by running `bin/tapioca gem open4`. 6 | 7 | # THIS IS AN EMPTY RBI FILE. 8 | # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires 9 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/packs@0.0.5.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `packs` gem. 5 | # Please instead update this file by running `bin/tapioca gem packs`. 6 | 7 | # source://packs//lib/packs/pack.rb#3 8 | module Packs 9 | class << self 10 | # source://packs//lib/packs.rb#16 11 | sig { returns(T::Array[::Packs::Pack]) } 12 | def all; end 13 | 14 | # source://packs//lib/packs.rb#34 15 | sig { void } 16 | def bust_cache!; end 17 | 18 | # source://packs//lib/packs.rb#41 19 | sig { returns(::Packs::Private::Configuration) } 20 | def config; end 21 | 22 | # @yield [config] 23 | # 24 | # source://packs//lib/packs.rb#47 25 | sig { params(blk: T.proc.params(arg0: ::Packs::Private::Configuration).void).void } 26 | def configure(&blk); end 27 | 28 | # source://packs//lib/packs.rb#21 29 | sig { params(name: ::String).returns(T.nilable(::Packs::Pack)) } 30 | def find(name); end 31 | 32 | # source://packs//lib/packs.rb#26 33 | sig { params(file_path: T.any(::Pathname, ::String)).returns(T.nilable(::Packs::Pack)) } 34 | def for_file(file_path); end 35 | 36 | private 37 | 38 | # source://packs//lib/packs.rb#73 39 | sig { returns(T::Array[::Pathname]) } 40 | def package_glob_patterns; end 41 | 42 | # source://packs//lib/packs.rb#59 43 | sig { returns(T::Hash[::String, ::Packs::Pack]) } 44 | def packs_by_name; end 45 | end 46 | end 47 | 48 | # source://packs//lib/packs.rb#10 49 | Packs::PACKAGE_FILE = T.let(T.unsafe(nil), String) 50 | 51 | # source://packs//lib/packs/pack.rb#4 52 | class Packs::Pack < ::T::Struct 53 | const :name, ::String 54 | const :path, ::Pathname 55 | const :relative_path, ::Pathname 56 | const :raw_hash, T::Hash[T.untyped, T.untyped] 57 | 58 | # source://packs//lib/packs/pack.rb#34 59 | sig { returns(::String) } 60 | def last_name; end 61 | 62 | # source://packs//lib/packs/pack.rb#39 63 | sig { returns(T::Hash[T.untyped, T.untyped]) } 64 | def metadata; end 65 | 66 | # source://packs//lib/packs/pack.rb#28 67 | sig { params(relative: T::Boolean).returns(::Pathname) } 68 | def yml(relative: T.unsafe(nil)); end 69 | 70 | class << self 71 | # source://packs//lib/packs/pack.rb#13 72 | sig { params(package_yml_absolute_path: ::Pathname).returns(::Packs::Pack) } 73 | def from(package_yml_absolute_path); end 74 | 75 | # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13 76 | def inherited(s); end 77 | end 78 | end 79 | 80 | # source://packs//lib/packs/private/configuration.rb#4 81 | module Packs::Private 82 | class << self 83 | # source://packs//lib/packs/private.rb#10 84 | sig { returns(::Pathname) } 85 | def root; end 86 | end 87 | end 88 | 89 | # source://packs//lib/packs/private/configuration.rb#5 90 | class Packs::Private::Configuration < ::T::Struct 91 | prop :pack_paths, T::Array[::String] 92 | 93 | class << self 94 | # source://packs//lib/packs/private/configuration.rb#17 95 | sig { returns(::Packs::Private::Configuration) } 96 | def fetch; end 97 | 98 | # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13 99 | def inherited(s); end 100 | 101 | # source://packs//lib/packs/private/configuration.rb#26 102 | sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) } 103 | def pack_paths(config_hash); end 104 | end 105 | end 106 | 107 | # source://packs//lib/packs/private/configuration.rb#7 108 | Packs::Private::Configuration::CONFIGURATION_PATHNAME = T.let(T.unsafe(nil), Pathname) 109 | 110 | # source://packs//lib/packs/private/configuration.rb#9 111 | Packs::Private::Configuration::DEFAULT_PACK_PATHS = T.let(T.unsafe(nil), Array) 112 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/parallel@1.22.1.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `parallel` gem. 5 | # Please instead update this file by running `bin/tapioca gem parallel`. 6 | 7 | module Parallel 8 | extend ::Parallel::ProcessorCount 9 | 10 | class << self 11 | # @return [Boolean] 12 | def all?(*args, &block); end 13 | 14 | # @return [Boolean] 15 | def any?(*args, &block); end 16 | 17 | def each(array, options = T.unsafe(nil), &block); end 18 | def each_with_index(array, options = T.unsafe(nil), &block); end 19 | def flat_map(*args, &block); end 20 | def in_processes(options = T.unsafe(nil), &block); end 21 | def in_threads(options = T.unsafe(nil)); end 22 | def map(source, options = T.unsafe(nil), &block); end 23 | def map_with_index(array, options = T.unsafe(nil), &block); end 24 | def worker_number; end 25 | 26 | # TODO: this does not work when doing threads in forks, so should remove and yield the number instead if needed 27 | def worker_number=(worker_num); end 28 | 29 | private 30 | 31 | def add_progress_bar!(job_factory, options); end 32 | def call_with_index(item, index, options, &block); end 33 | def create_workers(job_factory, options, &block); end 34 | 35 | # options is either a Integer or a Hash with :count 36 | def extract_count_from_options(options); end 37 | 38 | def instrument_finish(item, index, result, options); end 39 | def instrument_start(item, index, options); end 40 | def process_incoming_jobs(read, write, job_factory, options, &block); end 41 | def replace_worker(job_factory, workers, index, options, blk); end 42 | def with_instrumentation(item, index, options); end 43 | def work_direct(job_factory, options, &block); end 44 | def work_in_processes(job_factory, options, &blk); end 45 | def work_in_ractors(job_factory, options); end 46 | def work_in_threads(job_factory, options, &block); end 47 | def worker(job_factory, options, &block); end 48 | end 49 | end 50 | 51 | class Parallel::Break < ::StandardError 52 | # @return [Break] a new instance of Break 53 | def initialize(value = T.unsafe(nil)); end 54 | 55 | # Returns the value of attribute value. 56 | def value; end 57 | end 58 | 59 | class Parallel::DeadWorker < ::StandardError; end 60 | 61 | class Parallel::ExceptionWrapper 62 | # @return [ExceptionWrapper] a new instance of ExceptionWrapper 63 | def initialize(exception); end 64 | 65 | # Returns the value of attribute exception. 66 | def exception; end 67 | end 68 | 69 | class Parallel::JobFactory 70 | # @return [JobFactory] a new instance of JobFactory 71 | def initialize(source, mutex); end 72 | 73 | def next; end 74 | 75 | # generate item that is sent to workers 76 | # just index is faster + less likely to blow up with unserializable errors 77 | def pack(item, index); end 78 | 79 | def size; end 80 | 81 | # unpack item that is sent to workers 82 | def unpack(data); end 83 | 84 | private 85 | 86 | # @return [Boolean] 87 | def producer?; end 88 | 89 | def queue_wrapper(array); end 90 | end 91 | 92 | class Parallel::Kill < ::Parallel::Break; end 93 | 94 | # TODO: inline this method into parallel.rb and kill physical_processor_count in next major release 95 | module Parallel::ProcessorCount 96 | # Number of physical processor cores on the current system. 97 | def physical_processor_count; end 98 | 99 | # Number of processors seen by the OS, used for process scheduling 100 | def processor_count; end 101 | end 102 | 103 | Parallel::Stop = T.let(T.unsafe(nil), Object) 104 | 105 | class Parallel::UndumpableException < ::StandardError 106 | # @return [UndumpableException] a new instance of UndumpableException 107 | def initialize(original); end 108 | 109 | # Returns the value of attribute backtrace. 110 | def backtrace; end 111 | end 112 | 113 | class Parallel::UserInterruptHandler 114 | class << self 115 | def kill(thing); end 116 | 117 | # kill all these pids or threads if user presses Ctrl+c 118 | def kill_on_ctrl_c(pids, options); end 119 | 120 | private 121 | 122 | def restore_interrupt(old, signal); end 123 | def trap_interrupt(signal); end 124 | end 125 | end 126 | 127 | Parallel::UserInterruptHandler::INTERRUPT_SIGNAL = T.let(T.unsafe(nil), Symbol) 128 | Parallel::VERSION = T.let(T.unsafe(nil), String) 129 | Parallel::Version = T.let(T.unsafe(nil), String) 130 | 131 | class Parallel::Worker 132 | # @return [Worker] a new instance of Worker 133 | def initialize(read, write, pid); end 134 | 135 | # might be passed to started_processes and simultaneously closed by another thread 136 | # when running in isolation mode, so we have to check if it is closed before closing 137 | def close_pipes; end 138 | 139 | # Returns the value of attribute pid. 140 | def pid; end 141 | 142 | # Returns the value of attribute read. 143 | def read; end 144 | 145 | def stop; end 146 | 147 | # Returns the value of attribute thread. 148 | def thread; end 149 | 150 | # Sets the attribute thread 151 | # 152 | # @param value the value to set the attribute thread to. 153 | def thread=(_arg0); end 154 | 155 | def work(data); end 156 | 157 | # Returns the value of attribute write. 158 | def write; end 159 | 160 | private 161 | 162 | def wait; end 163 | end 164 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/parse_packwerk@0.18.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `parse_packwerk` gem. 5 | # Please instead update this file by running `bin/tapioca gem parse_packwerk`. 6 | 7 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#3 8 | module ParsePackwerk 9 | class << self 10 | # source://parse_packwerk//lib/parse_packwerk.rb#28 11 | sig { returns(T::Array[::ParsePackwerk::Package]) } 12 | def all; end 13 | 14 | # source://parse_packwerk//lib/parse_packwerk.rb#110 15 | sig { void } 16 | def bust_cache!; end 17 | 18 | # source://parse_packwerk//lib/parse_packwerk.rb#33 19 | sig { params(name: ::String).returns(T.nilable(::ParsePackwerk::Package)) } 20 | def find(name); end 21 | 22 | # source://parse_packwerk//lib/parse_packwerk.rb#43 23 | sig { params(file_path: T.any(::Pathname, ::String)).returns(::ParsePackwerk::Package) } 24 | def package_from_path(file_path); end 25 | 26 | # source://parse_packwerk//lib/parse_packwerk.rb#54 27 | sig { params(package: ::ParsePackwerk::Package).void } 28 | def write_package_yml!(package); end 29 | 30 | # source://parse_packwerk//lib/parse_packwerk.rb#38 31 | sig { returns(::ParsePackwerk::Configuration) } 32 | def yml; end 33 | 34 | private 35 | 36 | # We memoize packages_by_name for fast lookup. 37 | # Since Graph is an immutable value object, we can create indexes and general caching mechanisms safely. 38 | # 39 | # source://parse_packwerk//lib/parse_packwerk.rb#98 40 | sig { returns(T::Hash[::String, ::ParsePackwerk::Package]) } 41 | def packages_by_name; end 42 | end 43 | end 44 | 45 | # source://parse_packwerk//lib/parse_packwerk/configuration.rb#4 46 | class ParsePackwerk::Configuration < ::T::Struct 47 | const :exclude, T::Array[::String] 48 | const :package_paths, T::Array[::String] 49 | 50 | class << self 51 | # source://parse_packwerk//lib/parse_packwerk/configuration.rb#28 52 | sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) } 53 | def excludes(config_hash); end 54 | 55 | # source://parse_packwerk//lib/parse_packwerk/configuration.rb#11 56 | sig { returns(::ParsePackwerk::Configuration) } 57 | def fetch; end 58 | 59 | # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13 60 | def inherited(s); end 61 | 62 | # source://parse_packwerk//lib/parse_packwerk/configuration.rb#40 63 | sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) } 64 | def package_paths(config_hash); end 65 | end 66 | end 67 | 68 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#22 69 | ParsePackwerk::DEFAULT_EXCLUDE_GLOBS = T.let(T.unsafe(nil), Array) 70 | 71 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#23 72 | ParsePackwerk::DEFAULT_PACKAGE_PATHS = T.let(T.unsafe(nil), Array) 73 | 74 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#24 75 | ParsePackwerk::DEFAULT_PUBLIC_PATH = T.let(T.unsafe(nil), String) 76 | 77 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#14 78 | ParsePackwerk::DEPENDENCIES = T.let(T.unsafe(nil), String) 79 | 80 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#10 81 | ParsePackwerk::DEPENDENCY_VIOLATION_TYPE = T.let(T.unsafe(nil), String) 82 | 83 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#8 84 | ParsePackwerk::ENFORCE_DEPENDENCIES = T.let(T.unsafe(nil), String) 85 | 86 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#9 87 | ParsePackwerk::ENFORCE_PRIVACY = T.let(T.unsafe(nil), String) 88 | 89 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#13 90 | ParsePackwerk::METADATA = T.let(T.unsafe(nil), String) 91 | 92 | # Since this metadata is unstructured YAML, it could be any type. We leave it to clients of `ParsePackwerk::Package` 93 | # to add types based on their known usage of metadata. 94 | # 95 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#18 96 | ParsePackwerk::MetadataYmlType = T.type_alias { T::Hash[T.untyped, T.untyped] } 97 | 98 | # source://parse_packwerk//lib/parse_packwerk.rb#14 99 | class ParsePackwerk::MissingConfiguration < ::StandardError 100 | # source://parse_packwerk//lib/parse_packwerk.rb#18 101 | sig { params(packwerk_file_name: ::Pathname).void } 102 | def initialize(packwerk_file_name); end 103 | end 104 | 105 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#7 106 | ParsePackwerk::PACKAGE_TODO_YML_NAME = T.let(T.unsafe(nil), String) 107 | 108 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#5 109 | ParsePackwerk::PACKAGE_YML_NAME = T.let(T.unsafe(nil), String) 110 | 111 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#6 112 | ParsePackwerk::PACKWERK_YML_NAME = T.let(T.unsafe(nil), String) 113 | 114 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#11 115 | ParsePackwerk::PRIVACY_VIOLATION_TYPE = T.let(T.unsafe(nil), String) 116 | 117 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#12 118 | ParsePackwerk::PUBLIC_PATH = T.let(T.unsafe(nil), String) 119 | 120 | # source://parse_packwerk//lib/parse_packwerk/package.rb#4 121 | class ParsePackwerk::Package < ::T::Struct 122 | const :name, ::String 123 | const :enforce_dependencies, T.any(::String, T::Boolean) 124 | const :enforce_privacy, T.any(::String, T::Boolean) 125 | const :public_path, ::String, default: T.unsafe(nil) 126 | const :metadata, T::Hash[T.untyped, T.untyped] 127 | const :dependencies, T::Array[::String] 128 | const :config, T::Hash[T.untyped, T.untyped] 129 | 130 | # source://parse_packwerk//lib/parse_packwerk/package.rb#37 131 | sig { returns(::Pathname) } 132 | def directory; end 133 | 134 | # source://parse_packwerk//lib/parse_packwerk/package.rb#47 135 | sig { returns(T.any(::String, T::Boolean)) } 136 | def enforces_dependencies?; end 137 | 138 | # source://parse_packwerk//lib/parse_packwerk/package.rb#52 139 | sig { returns(T.any(::String, T::Boolean)) } 140 | def enforces_privacy?; end 141 | 142 | # source://parse_packwerk//lib/parse_packwerk/package.rb#42 143 | sig { returns(::Pathname) } 144 | def public_directory; end 145 | 146 | # source://parse_packwerk//lib/parse_packwerk/package.rb#57 147 | sig { returns(T::Array[::ParsePackwerk::Violation]) } 148 | def violations; end 149 | 150 | # source://parse_packwerk//lib/parse_packwerk/package.rb#32 151 | sig { returns(::Pathname) } 152 | def yml; end 153 | 154 | class << self 155 | # source://parse_packwerk//lib/parse_packwerk/package.rb#16 156 | sig { params(pathname: ::Pathname).returns(::ParsePackwerk::Package) } 157 | def from(pathname); end 158 | 159 | # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13 160 | def inherited(s); end 161 | end 162 | end 163 | 164 | # source://parse_packwerk//lib/parse_packwerk/package_set.rb#8 165 | class ParsePackwerk::PackageSet 166 | class << self 167 | # source://parse_packwerk//lib/parse_packwerk/package_set.rb#12 168 | sig do 169 | params( 170 | package_pathspec: T::Array[::String], 171 | exclude_pathspec: T::Array[::String] 172 | ).returns(T::Array[::ParsePackwerk::Package]) 173 | end 174 | def from(package_pathspec:, exclude_pathspec:); end 175 | 176 | private 177 | 178 | # source://parse_packwerk//lib/parse_packwerk/package_set.rb#28 179 | sig { params(globs: T::Array[::String], path: ::Pathname).returns(T::Boolean) } 180 | def exclude_path?(globs, path); end 181 | end 182 | end 183 | 184 | # source://parse_packwerk//lib/parse_packwerk/package_todo.rb#4 185 | class ParsePackwerk::PackageTodo < ::T::Struct 186 | const :pathname, ::Pathname 187 | const :violations, T::Array[::ParsePackwerk::Violation] 188 | 189 | class << self 190 | # source://parse_packwerk//lib/parse_packwerk/package_todo.rb#11 191 | sig { params(package: ::ParsePackwerk::Package).returns(::ParsePackwerk::PackageTodo) } 192 | def for(package); end 193 | 194 | # source://parse_packwerk//lib/parse_packwerk/package_todo.rb#17 195 | sig { params(pathname: ::Pathname).returns(::ParsePackwerk::PackageTodo) } 196 | def from(pathname); end 197 | 198 | # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13 199 | def inherited(s); end 200 | end 201 | end 202 | 203 | # source://parse_packwerk//lib/parse_packwerk/constants.rb#4 204 | ParsePackwerk::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String) 205 | 206 | # source://parse_packwerk//lib/parse_packwerk/violation.rb#4 207 | class ParsePackwerk::Violation < ::T::Struct 208 | const :type, ::String 209 | const :to_package_name, ::String 210 | const :class_name, ::String 211 | const :files, T::Array[::String] 212 | 213 | # source://parse_packwerk//lib/parse_packwerk/violation.rb#13 214 | sig { returns(T::Boolean) } 215 | def dependency?; end 216 | 217 | # source://parse_packwerk//lib/parse_packwerk/violation.rb#18 218 | sig { returns(T::Boolean) } 219 | def privacy?; end 220 | 221 | class << self 222 | # source://sorbet-runtime/0.5.10588/lib/types/struct.rb#13 223 | def inherited(s); end 224 | end 225 | end 226 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/racc@1.6.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `racc` gem. 5 | # Please instead update this file by running `bin/tapioca gem racc`. 6 | 7 | ParseError = Racc::ParseError 8 | Racc::Copyright = T.let(T.unsafe(nil), String) 9 | 10 | class Racc::Parser 11 | def _racc_do_parse_rb(arg, in_debug); end 12 | def _racc_do_reduce(arg, act); end 13 | 14 | # common 15 | def _racc_evalact(act, arg); end 16 | 17 | def _racc_init_sysvars; end 18 | def _racc_setup; end 19 | def _racc_yyparse_rb(recv, mid, arg, c_debug); end 20 | 21 | # The method to fetch next token. 22 | # If you use #do_parse method, you must implement #next_token. 23 | # 24 | # The format of return value is [TOKEN_SYMBOL, VALUE]. 25 | # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT 26 | # for 'IDENT'. ";" (String) for ';'. 27 | # 28 | # The final symbol (End of file) must be false. 29 | # 30 | # @raise [NotImplementedError] 31 | def next_token; end 32 | 33 | # This method is called when a parse error is found. 34 | # 35 | # ERROR_TOKEN_ID is an internal ID of token which caused error. 36 | # You can get string representation of this ID by calling 37 | # #token_to_str. 38 | # 39 | # ERROR_VALUE is a value of error token. 40 | # 41 | # value_stack is a stack of symbol values. 42 | # DO NOT MODIFY this object. 43 | # 44 | # This method raises ParseError by default. 45 | # 46 | # If this method returns, parsers enter "error recovering mode". 47 | # 48 | # @raise [ParseError] 49 | def on_error(t, val, vstack); end 50 | 51 | def racc_accept; end 52 | def racc_e_pop(state, tstack, vstack); end 53 | def racc_next_state(curstate, state); end 54 | def racc_print_stacks(t, v); end 55 | def racc_print_states(s); end 56 | 57 | # For debugging output 58 | def racc_read_token(t, tok, val); end 59 | 60 | def racc_reduce(toks, sim, tstack, vstack); end 61 | def racc_shift(tok, tstack, vstack); end 62 | def racc_token2str(tok); end 63 | 64 | # Convert internal ID of token symbol to the string. 65 | def token_to_str(t); end 66 | 67 | # Exit parser. 68 | # Return value is +Symbol_Value_Stack[0]+. 69 | def yyaccept; end 70 | 71 | # Leave error recovering mode. 72 | def yyerrok; end 73 | 74 | # Enter error recovering mode. 75 | # This method does not call #on_error. 76 | def yyerror; end 77 | 78 | class << self 79 | def racc_runtime_type; end 80 | end 81 | end 82 | 83 | Racc::Parser::Racc_Main_Parsing_Routine = T.let(T.unsafe(nil), Symbol) 84 | Racc::Parser::Racc_Runtime_Core_Id_C = T.let(T.unsafe(nil), String) 85 | Racc::Parser::Racc_Runtime_Core_Version = T.let(T.unsafe(nil), String) 86 | Racc::Parser::Racc_Runtime_Core_Version_C = T.let(T.unsafe(nil), String) 87 | Racc::Parser::Racc_Runtime_Core_Version_R = T.let(T.unsafe(nil), String) 88 | Racc::Parser::Racc_Runtime_Type = T.let(T.unsafe(nil), String) 89 | Racc::Parser::Racc_Runtime_Version = T.let(T.unsafe(nil), String) 90 | Racc::Parser::Racc_YY_Parse_Method = T.let(T.unsafe(nil), Symbol) 91 | Racc::VERSION = T.let(T.unsafe(nil), String) 92 | Racc::Version = T.let(T.unsafe(nil), String) 93 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/rails-dom-testing@2.0.3.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `rails-dom-testing` gem. 5 | # Please instead update this file by running `bin/tapioca gem rails-dom-testing`. 6 | 7 | # THIS IS AN EMPTY RBI FILE. 8 | # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires 9 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/rainbow@3.1.1.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `rainbow` gem. 5 | # Please instead update this file by running `bin/tapioca gem rainbow`. 6 | 7 | module Rainbow 8 | class << self 9 | def enabled; end 10 | def enabled=(value); end 11 | def global; end 12 | def new; end 13 | def uncolor(string); end 14 | end 15 | end 16 | 17 | class Rainbow::Color 18 | # Returns the value of attribute ground. 19 | def ground; end 20 | 21 | class << self 22 | def build(ground, values); end 23 | def parse_hex_color(hex); end 24 | end 25 | end 26 | 27 | class Rainbow::Color::Indexed < ::Rainbow::Color 28 | # @return [Indexed] a new instance of Indexed 29 | def initialize(ground, num); end 30 | 31 | def codes; end 32 | 33 | # Returns the value of attribute num. 34 | def num; end 35 | end 36 | 37 | class Rainbow::Color::Named < ::Rainbow::Color::Indexed 38 | # @return [Named] a new instance of Named 39 | def initialize(ground, name); end 40 | 41 | class << self 42 | def color_names; end 43 | def valid_names; end 44 | end 45 | end 46 | 47 | Rainbow::Color::Named::NAMES = T.let(T.unsafe(nil), Hash) 48 | 49 | class Rainbow::Color::RGB < ::Rainbow::Color::Indexed 50 | # @return [RGB] a new instance of RGB 51 | def initialize(ground, *values); end 52 | 53 | # Returns the value of attribute b. 54 | def b; end 55 | 56 | def codes; end 57 | 58 | # Returns the value of attribute g. 59 | def g; end 60 | 61 | # Returns the value of attribute r. 62 | def r; end 63 | 64 | private 65 | 66 | def code_from_rgb; end 67 | 68 | class << self 69 | def to_ansi_domain(value); end 70 | end 71 | end 72 | 73 | class Rainbow::Color::X11Named < ::Rainbow::Color::RGB 74 | include ::Rainbow::X11ColorNames 75 | 76 | # @return [X11Named] a new instance of X11Named 77 | def initialize(ground, name); end 78 | 79 | class << self 80 | def color_names; end 81 | def valid_names; end 82 | end 83 | end 84 | 85 | class Rainbow::NullPresenter < ::String 86 | def background(*_values); end 87 | def bg(*_values); end 88 | def black; end 89 | def blink; end 90 | def blue; end 91 | def bold; end 92 | def bright; end 93 | def color(*_values); end 94 | def cross_out; end 95 | def cyan; end 96 | def dark; end 97 | def faint; end 98 | def fg(*_values); end 99 | def foreground(*_values); end 100 | def green; end 101 | def hide; end 102 | def inverse; end 103 | def italic; end 104 | def magenta; end 105 | def method_missing(method_name, *args); end 106 | def red; end 107 | def reset; end 108 | def strike; end 109 | def underline; end 110 | def white; end 111 | def yellow; end 112 | 113 | private 114 | 115 | # @return [Boolean] 116 | def respond_to_missing?(method_name, *args); end 117 | end 118 | 119 | class Rainbow::Presenter < ::String 120 | # Sets background color of this text. 121 | def background(*values); end 122 | 123 | # Sets background color of this text. 124 | def bg(*values); end 125 | 126 | def black; end 127 | 128 | # Turns on blinking attribute for this text (not well supported by terminal 129 | # emulators). 130 | def blink; end 131 | 132 | def blue; end 133 | 134 | # Turns on bright/bold for this text. 135 | def bold; end 136 | 137 | # Turns on bright/bold for this text. 138 | def bright; end 139 | 140 | # Sets color of this text. 141 | def color(*values); end 142 | 143 | def cross_out; end 144 | def cyan; end 145 | 146 | # Turns on faint/dark for this text (not well supported by terminal 147 | # emulators). 148 | def dark; end 149 | 150 | # Turns on faint/dark for this text (not well supported by terminal 151 | # emulators). 152 | def faint; end 153 | 154 | # Sets color of this text. 155 | def fg(*values); end 156 | 157 | # Sets color of this text. 158 | def foreground(*values); end 159 | 160 | def green; end 161 | 162 | # Hides this text (set its color to the same as background). 163 | def hide; end 164 | 165 | # Inverses current foreground/background colors. 166 | def inverse; end 167 | 168 | # Turns on italic style for this text (not well supported by terminal 169 | # emulators). 170 | def italic; end 171 | 172 | def magenta; end 173 | 174 | # We take care of X11 color method call here. 175 | # Such as #aqua, #ghostwhite. 176 | def method_missing(method_name, *args); end 177 | 178 | def red; end 179 | 180 | # Resets terminal to default colors/backgrounds. 181 | # 182 | # It shouldn't be needed to use this method because all methods 183 | # append terminal reset code to end of string. 184 | def reset; end 185 | 186 | def strike; end 187 | 188 | # Turns on underline decoration for this text. 189 | def underline; end 190 | 191 | def white; end 192 | def yellow; end 193 | 194 | private 195 | 196 | # @return [Boolean] 197 | def respond_to_missing?(method_name, *args); end 198 | 199 | def wrap_with_sgr(codes); end 200 | end 201 | 202 | Rainbow::Presenter::TERM_EFFECTS = T.let(T.unsafe(nil), Hash) 203 | 204 | class Rainbow::StringUtils 205 | class << self 206 | def uncolor(string); end 207 | def wrap_with_sgr(string, codes); end 208 | end 209 | end 210 | 211 | class Rainbow::Wrapper 212 | # @return [Wrapper] a new instance of Wrapper 213 | def initialize(enabled = T.unsafe(nil)); end 214 | 215 | # Returns the value of attribute enabled. 216 | def enabled; end 217 | 218 | # Sets the attribute enabled 219 | # 220 | # @param value the value to set the attribute enabled to. 221 | def enabled=(_arg0); end 222 | 223 | def wrap(string); end 224 | end 225 | 226 | module Rainbow::X11ColorNames; end 227 | Rainbow::X11ColorNames::NAMES = T.let(T.unsafe(nil), Hash) 228 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/rspec@3.11.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `rspec` gem. 5 | # Please instead update this file by running `bin/tapioca gem rspec`. 6 | 7 | module RSpec 8 | extend ::RSpec::Support::Warnings 9 | extend ::RSpec::Core::Warnings 10 | 11 | class << self 12 | def clear_examples; end 13 | def configuration; end 14 | def configuration=(_arg0); end 15 | def configure; end 16 | def const_missing(name); end 17 | def context(*args, &example_group_block); end 18 | def current_example; end 19 | def current_example=(example); end 20 | def current_scope; end 21 | def current_scope=(scope); end 22 | def describe(*args, &example_group_block); end 23 | def example_group(*args, &example_group_block); end 24 | def fcontext(*args, &example_group_block); end 25 | def fdescribe(*args, &example_group_block); end 26 | def reset; end 27 | def shared_context(name, *args, &block); end 28 | def shared_examples(name, *args, &block); end 29 | def shared_examples_for(name, *args, &block); end 30 | def world; end 31 | def world=(_arg0); end 32 | def xcontext(*args, &example_group_block); end 33 | def xdescribe(*args, &example_group_block); end 34 | end 35 | end 36 | 37 | RSpec::MODULES_TO_AUTOLOAD = T.let(T.unsafe(nil), Hash) 38 | RSpec::SharedContext = RSpec::Core::SharedContext 39 | module RSpec::Version; end 40 | RSpec::Version::STRING = T.let(T.unsafe(nil), String) 41 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `ruby2_keywords` gem. 5 | # Please instead update this file by running `bin/tapioca gem ruby2_keywords`. 6 | 7 | # THIS IS AN EMPTY RBI FILE. 8 | # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires 9 | -------------------------------------------------------------------------------- /sorbet/rbi/gems/unicode-display_width@2.3.0.rbi: -------------------------------------------------------------------------------- 1 | # typed: true 2 | 3 | # DO NOT EDIT MANUALLY 4 | # This is an autogenerated file for types exported from the `unicode-display_width` gem. 5 | # Please instead update this file by running `bin/tapioca gem unicode-display_width`. 6 | 7 | module Unicode; end 8 | 9 | class Unicode::DisplayWidth 10 | # @return [DisplayWidth] a new instance of DisplayWidth 11 | def initialize(ambiguous: T.unsafe(nil), overwrite: T.unsafe(nil), emoji: T.unsafe(nil)); end 12 | 13 | def get_config(**kwargs); end 14 | def of(string, **kwargs); end 15 | 16 | class << self 17 | def emoji_extra_width_of(string, ambiguous = T.unsafe(nil), overwrite = T.unsafe(nil), _ = T.unsafe(nil)); end 18 | def of(string, ambiguous = T.unsafe(nil), overwrite = T.unsafe(nil), options = T.unsafe(nil)); end 19 | end 20 | end 21 | 22 | Unicode::DisplayWidth::DATA_DIRECTORY = T.let(T.unsafe(nil), String) 23 | Unicode::DisplayWidth::DEPTHS = T.let(T.unsafe(nil), Array) 24 | Unicode::DisplayWidth::INDEX = T.let(T.unsafe(nil), Array) 25 | Unicode::DisplayWidth::INDEX_FILENAME = T.let(T.unsafe(nil), String) 26 | Unicode::DisplayWidth::UNICODE_VERSION = T.let(T.unsafe(nil), String) 27 | Unicode::DisplayWidth::VERSION = T.let(T.unsafe(nil), String) 28 | -------------------------------------------------------------------------------- /sorbet/rbi/todo.rbi: -------------------------------------------------------------------------------- 1 | module ::RSpec 2 | module Matchers; end 3 | end 4 | 5 | # typed: true 6 | 7 | class Danger::DangerfileGitHubPlugin < ::Danger::Plugin 8 | def initialize(dangerfile); end 9 | 10 | def api; end 11 | def base_commit; end 12 | def branch_for_base; end 13 | def branch_for_head; end 14 | def dismiss_out_of_range_messages(dismiss = T.unsafe(nil)); end 15 | def head_commit; end 16 | def html_link(paths, full_path: T.unsafe(nil)); end 17 | def mr_author; end 18 | def mr_body; end 19 | def mr_json; end 20 | def mr_labels; end 21 | def mr_title; end 22 | def pr_author; end 23 | def pr_body; end 24 | def pr_diff; end 25 | def pr_draft?; end 26 | def pr_json; end 27 | def pr_labels; end 28 | def pr_title; end 29 | def review; end 30 | 31 | private 32 | 33 | def create_link(href, text); end 34 | 35 | class << self 36 | def instance_name; end 37 | def new(dangerfile); end 38 | end 39 | end 40 | 41 | class Danger::CI 42 | def initialize(_env); end 43 | 44 | def pull_request_id; end 45 | def pull_request_id=(_arg0); end 46 | def repo_slug; end 47 | def repo_slug=(_arg0); end 48 | def repo_url; end 49 | def repo_url=(_arg0); end 50 | def supported_request_sources; end 51 | def supported_request_sources=(_arg0); end 52 | def supports?(request_source); end 53 | 54 | class << self 55 | def available_ci_sources; end 56 | def inherited(child_class); end 57 | def validates_as_ci?(_env); end 58 | def validates_as_pr?(_env); end 59 | end 60 | end 61 | 62 | class Danger::LocalGitRepo < ::Danger::CI 63 | def initialize(env = T.unsafe(nil)); end 64 | 65 | def base_commit; end 66 | def base_commit=(_arg0); end 67 | def git; end 68 | def head_commit; end 69 | def head_commit=(_arg0); end 70 | def run_git(command); end 71 | def supported_request_sources; end 72 | 73 | private 74 | 75 | def commits; end 76 | def find_pull_request(env); end 77 | def find_remote_info(env); end 78 | def found_pull_request; end 79 | def given_pull_request_url?(env); end 80 | def missing_remote_error_message; end 81 | def raise_error_for_missing_remote; end 82 | def remote_info; end 83 | def sha; end 84 | 85 | class << self 86 | def validates_as_ci?(env); end 87 | def validates_as_pr?(_env); end 88 | end 89 | end 90 | 91 | 92 | class Danger::DangerfileGitPlugin < ::Danger::Plugin 93 | def initialize(dangerfile); end 94 | 95 | def added_files; end 96 | def commits; end 97 | def deleted_files; end 98 | def deletions; end 99 | def diff; end 100 | def diff_for_file(file); end 101 | def info_for_file(file); end 102 | def insertions; end 103 | def lines_of_code; end 104 | def modified_files; end 105 | def renamed_files; end 106 | def tags; end 107 | 108 | class << self 109 | def instance_name; end 110 | end 111 | end 112 | 113 | 114 | class Danger::Plugin 115 | sig { returns(Danger::DangerfileGitHubPlugin) } 116 | def github; end 117 | 118 | sig { returns(Danger::DangerfileGitPlugin) } 119 | def git; end 120 | 121 | def markdown(message, file:, line:); end 122 | end 123 | 124 | class Danger::Dangerfile; end 125 | module DangerHelpers::Cork::Board; end 126 | -------------------------------------------------------------------------------- /sorbet/tapioca/require.rb: -------------------------------------------------------------------------------- 1 | require 'packwerk' 2 | require 'danger' 3 | # This triggers the autoload in packwerk so types for this constant are defined 4 | Packwerk::RailsLoadPaths 5 | -------------------------------------------------------------------------------- /spec/danger_packwerk/basic_reference_offense_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | module DangerPackwerk 4 | RSpec.describe BasicReferenceOffense do 5 | let(:package_yml) { 'packs/some_pack/package.yml' } 6 | let(:package_todo_yml) { 'packs/some_pack/package_todo.yml' } 7 | let(:plugin) { dangerfile.packwerk } 8 | 9 | before do 10 | write_file(package_yml, <<~YML) 11 | enforce_privacy: true 12 | enforce_dependencies: true 13 | YML 14 | 15 | write_file(package_todo_yml, <<~YML) 16 | packs/other_pack: 17 | "::OtherPack::ClassName": 18 | violations: 19 | - dependency 20 | files: 21 | - packs/some_pack/file.rb 22 | ? "::OtherPack::ReallyLongClassNameThatCausesSerializerToUseExplicitMappingYamlSyntax" 23 | : violations: 24 | - dependency 25 | files: 26 | - packs/some_pack/file.rb 27 | YML 28 | end 29 | 30 | # If a class name is long, it can cause the YAML serializer generating 31 | # these files to use the explicit mapping syntax that breaks the key onto 32 | # multiple lines. It's valid YAML, but an edge case that can cause issues 33 | # for libraries like this one. 34 | # * https://github.com/prettier/prettier/issues/5599 35 | # * https://github.com/jeremyfa/yaml.js/issues/128 36 | it 'can parse yaml that contains explicit mapping syntax' do 37 | offenses = described_class.from(package_todo_yml) 38 | expect(offenses.count).to eq(2) 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'bundler/setup' 4 | require 'cork' 5 | require 'json' 6 | require 'packs' 7 | require 'packs/rspec/support' 8 | 9 | module DangerHelpers 10 | # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb 11 | # If you are expanding these files, see if it's already been done ^. 12 | 13 | def testing_ui 14 | @output = StringIO.new 15 | 16 | cork = Cork::Board.new(out: @output) 17 | def cork.string 18 | out.string.gsub(/\e\[([;\d]+)?m/, '') 19 | end 20 | cork 21 | end 22 | 23 | # Example environment (ENV) that would come from 24 | # running a PR on Buildkite 25 | def testing_env 26 | { 27 | 'BUILDKITE_REPO' => 'git@github.com:rubyatscale/danger-packwerk.git', 28 | 'BUILDKITE' => true, 29 | 'DANGER_GITHUB_API_TOKEN' => 'some_token', 30 | 'DANGER_GITHUB_BEARER_TOKEN' => 'some_other_token' 31 | } 32 | end 33 | 34 | # A stubbed out Dangerfile for use in tests 35 | def testing_dangerfile 36 | env = Danger::EnvironmentManager.new(testing_env) 37 | Danger::Dangerfile.new(env, testing_ui) 38 | end 39 | end 40 | 41 | require 'pry' 42 | require_relative 'support/danger_plugin' 43 | require_relative 'support/custom_matchers' 44 | require 'danger-packwerk' 45 | 46 | RSpec.configure do |config| 47 | # Enable flags like --only-failures and --next-failure 48 | config.example_status_persistence_file_path = '.rspec_status' 49 | 50 | # Disable RSpec exposing methods globally on `Module` and `main` 51 | config.disable_monkey_patching! 52 | config.include_context 'danger plugin' 53 | 54 | config.expect_with :rspec do |c| 55 | c.syntax = :expect 56 | end 57 | 58 | config.include DangerHelpers 59 | 60 | config.before do |_example| 61 | ParsePackwerk.bust_cache! 62 | allow(Packwerk::RailsLoadPaths).to receive(:extract_relevant_paths).and_return({}) 63 | end 64 | end 65 | 66 | def sorbet_double(stubbed_class, attr_map = {}) 67 | instance_double(stubbed_class, attr_map).tap do |dbl| 68 | allow(dbl).to receive(:is_a?) { |tested_class| stubbed_class.ancestors.include?(tested_class) } 69 | end 70 | end 71 | 72 | def write_package_yml( 73 | pack_name 74 | ) 75 | write_pack(pack_name, { 'enforce_dependencies' => true, 'enforce_privacy' => true }) 76 | end 77 | -------------------------------------------------------------------------------- /spec/support/custom_matchers.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | RSpec::Matchers.define(:contain_inline_markdown) do |expected_visualized_message, overridden_filename| 4 | match do |file_with_markdown| 5 | # TODO: get this intelligently 6 | actual_markdowns = dangerfile.status_report[:markdowns] 7 | @markdown = actual_markdowns.first 8 | 9 | @danger_start_sigil = '==================== DANGER_START' 10 | @danger_end_sigil = '==================== DANGER_END' 11 | @match = expected_visualized_message.match(/.*?(#{@danger_start_sigil}\n(.*?)#{@danger_end_sigil}\n).*?/m) 12 | if @match.nil? 13 | false 14 | else 15 | @expected_message = @match[2] 16 | @expected_message_including_sigils = @match[1] 17 | @expected_file_contents = expected_visualized_message.gsub(@expected_message_including_sigils, '').chomp 18 | @actual_file_contents = File.read(file_with_markdown) 19 | @expected_line = expected_visualized_message.split("\n").find_index { |line| line == @danger_start_sigil } 20 | @expected_filename = overridden_filename || file_with_markdown 21 | 22 | [ 23 | @matching_message = @markdown.message == @expected_message, 24 | @matching_line = @markdown.line == @expected_line, 25 | @matching_file = @markdown.file == @expected_filename, 26 | @matching_file_contents = @expected_file_contents == @actual_file_contents 27 | ].all? 28 | end 29 | end 30 | 31 | failure_message do 32 | if @match.nil? 33 | <<~FAILURE_MESSAGE 34 | Could not find matching markdown in #{@expected_filename}. Make sure to use #{@danger_start_sigil} and #{@danger_end_sigil} 35 | at the beginning of your heredoc to match a markdown message. 36 | FAILURE_MESSAGE 37 | elsif !@matching_message 38 | expect(@markdown.message).to eq @expected_message 39 | elsif !@matching_line 40 | expect(@markdown.line).to eq @expected_line 41 | elsif !@matching_file 42 | expect(@markdown.file).to eq @expected_filename 43 | elsif !@matching_file_contents 44 | expect(@actual_file_contents).to eq @expected_file_contents 45 | end 46 | end 47 | 48 | chain :and_nothing_else do 49 | expect(dangerfile.status_report[:warnings]).to be_empty 50 | expect(dangerfile.status_report[:errors]).to be_empty 51 | expect(dangerfile.status_report[:markdowns].count).to eq 1 52 | end 53 | end 54 | 55 | RSpec::Matchers.define(:produce_no_danger_messages) do 56 | match do |dangerfile| 57 | expect_dangerfile_to_produce_no_danger_messages dangerfile 58 | end 59 | 60 | failure_message do |dangerfile| 61 | expect_dangerfile_to_produce_no_danger_messages dangerfile 62 | end 63 | end 64 | 65 | def expect_dangerfile_to_produce_no_danger_messages(dangerfile) 66 | expect(dangerfile.status_report[:warnings]).to be_empty 67 | expect(dangerfile.status_report[:errors]).to be_empty 68 | expect(dangerfile.status_report[:markdowns]).to be_empty 69 | expect(dangerfile.status_report[:messages]).to be_empty 70 | end 71 | -------------------------------------------------------------------------------- /spec/support/danger_plugin.rb: -------------------------------------------------------------------------------- 1 | RSpec.shared_context 'danger plugin' do 2 | let(:dangerfile) { testing_dangerfile } 3 | let(:modified_files) { [] } 4 | let(:added_files) { [] } 5 | let(:deleted_files) { [] } 6 | let(:renamed_files) { [] } 7 | let(:pr_json) do 8 | { 9 | head: { ref: 'my_branch' }, 10 | base: { 11 | repo: { 12 | html_url: 'https://github.com/MyOrg/my_repo', 13 | owner: { login: 'MyOrg' } 14 | } 15 | } 16 | } 17 | end 18 | let(:mock_git) { sorbet_double(Danger::DangerfileGitPlugin) } 19 | 20 | before do 21 | allow(mock_git).to receive_messages(modified_files: modified_files, added_files: added_files, deleted_files: deleted_files, renamed_files: renamed_files) 22 | allow(plugin).to receive(:git).and_return(mock_git) 23 | 24 | allow(plugin.github).to receive(:pr_json).and_return(pr_json) 25 | end 26 | end 27 | --------------------------------------------------------------------------------