Skip to content

Move danger libs to danger folder

Heinrich Lee Yu requested to merge move-danger-libs into master

What does this MR do?

This fixes the warnings we see when booting Rails:

/home/git/gitlab/lib/gitlab/danger/title_linting.rb:6: warning: already initialized constant Gitlab::Danger::TitleLinting::DRAFT_REGEX
/home/git/gitlab/lib/gitlab/danger/title_linting.rb:6: warning: previous definition of DRAFT_REGEX was here
/home/git/gitlab/lib/gitlab/danger/weightage.rb:6: warning: already initialized constant Gitlab::Danger::Weightage::CAPACITY_MULTIPLIER
/home/git/gitlab/lib/gitlab/danger/weightage.rb:6: warning: previous definition of CAPACITY_MULTIPLIER was here
/home/git/gitlab/lib/gitlab/danger/weightage.rb:7: warning: already initialized constant Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT
/home/git/gitlab/lib/gitlab/danger/weightage.rb:7: warning: previous definition of BASE_REVIEWER_WEIGHT was here
/home/git/gitlab/lib/gitlab/danger/weightage/reviewers.rb:22: warning: already initialized constant Gitlab::Danger::Weightage::Reviewers::DEFAULT_REVIEWER_WEIGHT
/home/git/gitlab/lib/gitlab/danger/weightage/reviewers.rb:22: warning: previous definition of DEFAULT_REVIEWER_WEIGHT was here
/home/git/gitlab/lib/gitlab/danger/weightage/reviewers.rb:23: warning: already initialized constant Gitlab::Danger::Weightage::Reviewers::TRAINTAINER_WEIGHT
/home/git/gitlab/lib/gitlab/danger/weightage/reviewers.rb:23: warning: previous definition of TRAINTAINER_WEIGHT was here

Those warnings are emitted because Rails autoloads these classes and then these classes have explicit requires because these are used in Rake / Danger where there is no autoloader. These cause these classes to be loaded twice when in the Rails context.

This change also means we no longer load these classes when booting or eager-loading our Rails app. We don't need these in that context anyway. This should also save us a tiny bit of Puma memory 🙂

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Heinrich Lee Yu

Merge request reports