Commit 4ec103c6 authored by Albert Salim's avatar Albert Salim Committed by Rémy Coutable

Remove conditional require lines

These were added because of Rails eagerload.
These files are now moved out of Rails eagerload path,
so the conditionals are not necessary.
parent a63eef73
......@@ -173,7 +173,7 @@
/.gitlab/CODEOWNERS @gl-quality/eng-prod
Dangerfile @gl-quality/eng-prod
/danger/ @gl-quality/eng-prod
/lib/gitlab/danger/ @gl-quality/eng-prod
/tooling/danger/ @gl-quality/eng-prod
/scripts/ @gl-quality/eng-prod
/scripts/frontend/ @gl-quality/eng-prod @gitlab-org/maintainers/frontend
/scripts/review_apps/seed-dast-test-data.sh @dappelt @ngeorge1 @gl-quality/eng-prod
......
......@@ -256,7 +256,7 @@ Gitlab/Json:
- 'scripts/**/*'
- 'lib/rspec_flaky/**/*'
- 'lib/quality/**/*'
- 'lib/gitlab/danger/**/*'
- 'tooling/danger/**/*'
Gitlab/AvoidUploadedFileFromParams:
Enabled: true
......
......@@ -141,7 +141,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
- 'ee/spec/lib/ee/gitlab/application_context_spec.rb'
- 'spec/helpers/visibility_level_helper_spec.rb'
- 'spec/lib/gitlab/conan_token_spec.rb'
- 'spec/lib/gitlab/danger/sidekiq_queues_spec.rb'
- 'spec/tooling/danger/sidekiq_queues_spec.rb'
- 'spec/lib/gitlab/git/conflict/parser_spec.rb'
- 'spec/lib/gitlab/graphql/lazy_spec.rb'
- 'spec/models/ci/build_trace_chunk_spec.rb'
......@@ -185,8 +185,8 @@ Lint/EmptyFile:
# Cop supports --auto-correct.
Lint/IdentityComparison:
Exclude:
- 'spec/lib/gitlab/danger/weightage/maintainers_spec.rb'
- 'spec/lib/gitlab/danger/weightage/reviewers_spec.rb'
- 'spec/tooling/danger/weightage/maintainers_spec.rb'
- 'spec/tooling/danger/weightage/reviewers_spec.rb'
# Offense count: 184
# Configuration parameters: MaximumRangeSize.
......@@ -263,7 +263,7 @@ Metrics/CyclomaticComplexity:
- 'lib/banzai/filter/abstract_reference_filter.rb'
- 'lib/declarative_policy/runner.rb'
- 'lib/gitlab/conflict/file.rb'
- 'lib/gitlab/danger/roulette.rb'
- 'tooling/danger/roulette.rb'
- 'lib/gitlab/diff/parser.rb'
- 'lib/gitlab/rack_attack.rb'
- 'lib/gitlab/sidekiq_cluster/cli.rb'
......@@ -285,7 +285,7 @@ Metrics/PerceivedComplexity:
- 'lib/banzai/renderer.rb'
- 'lib/declarative_policy/runner.rb'
- 'lib/gitlab/conflict/file.rb'
- 'lib/gitlab/danger/roulette.rb'
- 'tooling/danger/roulette.rb'
- 'lib/gitlab/rack_attack.rb'
- 'lib/gitlab/sidekiq_cluster/cli.rb'
- 'lib/gitlab/utils/merge_hash.rb'
......@@ -629,7 +629,7 @@ Rails/IndexBy:
- 'ee/lib/gitlab/analytics/type_of_work/tasks_by_type.rb'
- 'ee/lib/gitlab/elastic/document_reference.rb'
- 'ee/lib/gitlab/group_plans_preloader.rb'
- 'lib/gitlab/danger/sidekiq_queues.rb'
- 'tooling/danger/sidekiq_queues.rb'
- 'lib/gitlab/database/count/reltuples_count_strategy.rb'
- 'lib/gitlab/language_detection.rb'
......
# frozen_string_literal: true
require_relative 'lib/gitlab_danger'
require_relative 'lib/gitlab/danger/request_helper'
require_relative 'tooling/gitlab_danger'
require_relative 'tooling/danger/request_helper'
danger.import_plugin('danger/plugins/helper.rb')
danger.import_plugin('danger/plugins/roulette.rb')
......
# frozen_string_literal: true
require_relative File.expand_path('../../lib/gitlab/danger/commit_linter', __dir__)
require_relative File.expand_path('../../lib/gitlab/danger/merge_request_linter', __dir__)
require_relative File.expand_path('../../tooling/danger/commit_linter', __dir__)
require_relative File.expand_path('../../tooling/danger/merge_request_linter', __dir__)
COMMIT_MESSAGE_GUIDELINES = "https://docs.gitlab.com/ee/development/contributing/merge_request_workflow.html#commit-messages-guidelines"
MORE_INFO = "For more information, take a look at our [Commit message guidelines](#{COMMIT_MESSAGE_GUIDELINES})."
......@@ -54,7 +54,7 @@ end
# https://github.com/jonallured/danger-commit_lint because its output is not
# very helpful, and it doesn't offer the means of ignoring merge commits.
def lint_commit(commit)
linter = Gitlab::Danger::CommitLinter.new(commit)
linter = Tooling::Danger::CommitLinter.new(commit)
# For now we'll ignore merge commits, as getting rid of those is a problem
# separate from enforcing good commit messages.
......@@ -93,7 +93,7 @@ end
def lint_mr_title(mr_title)
commit = Struct.new(:message, :sha).new(mr_title)
Gitlab::Danger::MergeRequestLinter.new(commit).lint
Tooling::Danger::MergeRequestLinter.new(commit).lint
end
def count_non_fixup_commits(commit_linters)
......
# frozen_string_literal: true
require_relative '../../lib/gitlab/danger/changelog'
require_relative '../../tooling/danger/changelog'
module Danger
class Changelog < Plugin
# Put the helper code somewhere it can be tested
include Gitlab::Danger::Changelog
include Tooling::Danger::Changelog
end
end
# frozen_string_literal: true
require_relative '../../lib/gitlab/danger/helper'
require_relative '../../tooling/danger/helper'
module Danger
# Common helper functions for our danger scripts. See Gitlab::Danger::Helper
# Common helper functions for our danger scripts. See Tooling::Danger::Helper
# for more details
class Helper < Plugin
# Put the helper code somewhere it can be tested
include Gitlab::Danger::Helper
include Tooling::Danger::Helper
end
end
# frozen_string_literal: true
require_relative '../../lib/gitlab/danger/roulette'
require_relative '../../tooling/danger/roulette'
module Danger
class Roulette < Plugin
# Put the helper code somewhere it can be tested
include Gitlab::Danger::Roulette
include Tooling::Danger::Roulette
end
end
# frozen_string_literal: true
require_relative '../../lib/gitlab/danger/sidekiq_queues'
require_relative '../../tooling/danger/sidekiq_queues'
module Danger
class SidekiqQueues < Plugin
# Put the helper code somewhere it can be tested
include Gitlab::Danger::SidekiqQueues
include Tooling::Danger::SidekiqQueues
end
end
......@@ -35,7 +35,7 @@ UNKNOWN_FILES_MESSAGE = <<MARKDOWN
These files couldn't be categorised, so Danger was unable to suggest a reviewer.
Please consider creating a merge request to
[add support](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/danger/helper.rb)
[add support](https://gitlab.com/gitlab-org/gitlab/blob/master/tooling/danger/helper.rb)
for them.
MARKDOWN
......
......@@ -105,9 +105,9 @@ minimize the number of lines of code in `danger/`. A non-trivial `Dangerfile`
should mostly call plugin code with arguments derived from the methods provided
by Danger. The plugin code itself should have unit tests.
At present, we do this by putting the code in a module in `lib/gitlab/danger/...`,
At present, we do this by putting the code in a module in `tooling/danger/...`,
and including it in the matching `danger/plugins/...` file. Specs can then be
added in `spec/lib/gitlab/danger/...`.
added in `spec/tooling/danger/...`.
To determine if your `Dangerfile` works, push the branch that contains it to
GitLab. This can be quite frustrating, as it significantly increases the cycle
......
desc 'Run local Danger rules'
task :danger_local do
require 'gitlab_danger'
require_relative '../../tooling/gitlab_danger'
require 'gitlab/popen'
puts("#{GitlabDanger.local_warning_message}\n")
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require_relative 'danger_spec_helper'
require 'gitlab/danger/base_linter'
require_relative '../../../tooling/danger/base_linter'
RSpec.describe Gitlab::Danger::BaseLinter do
RSpec.describe Tooling::Danger::BaseLinter do
let(:commit_class) do
Struct.new(:message, :sha, :diff_parent)
end
......
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative 'danger_spec_helper'
require 'gitlab/danger/changelog'
require_relative '../../../tooling/danger/changelog'
RSpec.describe Gitlab::Danger::Changelog do
RSpec.describe Tooling::Danger::Changelog do
include DangerSpecHelper
let(:added_files) { nil }
......@@ -53,8 +52,8 @@ RSpec.describe Gitlab::Danger::Changelog do
describe '#optional?' do
let(:category_with_changelog) { :backend }
let(:label_with_changelog) { 'frontend' }
let(:category_without_changelog) { Gitlab::Danger::Changelog::NO_CHANGELOG_CATEGORIES.first }
let(:label_without_changelog) { Gitlab::Danger::Changelog::NO_CHANGELOG_LABELS.first }
let(:category_without_changelog) { Tooling::Danger::Changelog::NO_CHANGELOG_CATEGORIES.first }
let(:label_without_changelog) { Tooling::Danger::Changelog::NO_CHANGELOG_LABELS.first }
subject { changelog.optional? }
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require_relative 'danger_spec_helper'
require 'gitlab/danger/commit_linter'
require_relative '../../../tooling/danger/commit_linter'
RSpec.describe Gitlab::Danger::CommitLinter do
RSpec.describe Tooling::Danger::CommitLinter do
using RSpec::Parameterized::TableSyntax
let(:total_files_changed) { 2 }
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require 'gitlab/danger/emoji_checker'
require_relative '../../../tooling/danger/emoji_checker'
RSpec.describe Gitlab::Danger::EmojiChecker do
RSpec.describe Tooling::Danger::EmojiChecker do
using RSpec::Parameterized::TableSyntax
describe '#includes_text_emoji?' do
......
......@@ -4,9 +4,9 @@ require 'fast_spec_helper'
require 'rspec-parameterized'
require_relative 'danger_spec_helper'
require 'gitlab/danger/helper'
require_relative '../../../tooling/danger/helper'
RSpec.describe Gitlab::Danger::Helper do
RSpec.describe Tooling::Danger::Helper do
using RSpec::Parameterized::TableSyntax
include DangerSpecHelper
......@@ -37,7 +37,7 @@ RSpec.describe Gitlab::Danger::Helper do
context 'when danger gitlab plugin is not available' do
it 'returns nil' do
invalid_danger = Class.new do
include Gitlab::Danger::Helper
include Tooling::Danger::Helper
end.new
expect(invalid_danger.gitlab_helper).to be_nil
......@@ -289,8 +289,8 @@ RSpec.describe Gitlab::Danger::Helper do
'.gitlab/ci/cng.gitlab-ci.yml' | [:engineering_productivity]
'.gitlab/ci/ee-specific-checks.gitlab-ci.yml' | [:engineering_productivity]
'scripts/foo' | [:engineering_productivity]
'lib/gitlab/danger/foo' | [:engineering_productivity]
'ee/lib/gitlab/danger/foo' | [:engineering_productivity]
'tooling/danger/foo' | [:engineering_productivity]
'ee/tooling/danger/foo' | [:engineering_productivity]
'lefthook.yml' | [:engineering_productivity]
'.editorconfig' | [:engineering_productivity]
'tooling/bin/find_foss_tests' | [:engineering_productivity]
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require_relative 'danger_spec_helper'
require 'gitlab/danger/merge_request_linter'
require_relative '../../../tooling/danger/merge_request_linter'
RSpec.describe Gitlab::Danger::MergeRequestLinter do
RSpec.describe Tooling::Danger::MergeRequestLinter do
using RSpec::Parameterized::TableSyntax
let(:mr_class) do
......
......@@ -3,10 +3,10 @@
require 'webmock/rspec'
require 'timecop'
require 'gitlab/danger/roulette'
require_relative '../../../tooling/danger/roulette'
require 'active_support/testing/time_helpers'
RSpec.describe Gitlab::Danger::Roulette do
RSpec.describe Tooling::Danger::Roulette do
include ActiveSupport::Testing::TimeHelpers
around do |example|
......@@ -16,7 +16,7 @@ RSpec.describe Gitlab::Danger::Roulette do
let(:backend_available) { true }
let(:backend_tz_offset_hours) { 2.0 }
let(:backend_maintainer) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'backend-maintainer',
'name' => 'Backend maintainer',
'role' => 'Backend engineer',
......@@ -27,7 +27,7 @@ RSpec.describe Gitlab::Danger::Roulette do
end
let(:frontend_reviewer) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'frontend-reviewer',
'name' => 'Frontend reviewer',
'role' => 'Frontend engineer',
......@@ -38,7 +38,7 @@ RSpec.describe Gitlab::Danger::Roulette do
end
let(:frontend_maintainer) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'frontend-maintainer',
'name' => 'Frontend maintainer',
'role' => 'Frontend engineer',
......@@ -49,7 +49,7 @@ RSpec.describe Gitlab::Danger::Roulette do
end
let(:software_engineer_in_test) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'software-engineer-in-test',
'name' => 'Software Engineer in Test',
'role' => 'Software Engineer in Test, Create:Source Code',
......@@ -60,7 +60,7 @@ RSpec.describe Gitlab::Danger::Roulette do
end
let(:engineering_productivity_reviewer) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'eng-prod-reviewer',
'name' => 'EP engineer',
'role' => 'Engineering Productivity',
......@@ -71,7 +71,7 @@ RSpec.describe Gitlab::Danger::Roulette do
end
let(:ci_template_reviewer) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'ci-template-maintainer',
'name' => 'CI Template engineer',
'role' => '~"ci::templates"',
......@@ -121,7 +121,7 @@ RSpec.describe Gitlab::Danger::Roulette do
let!(:project) { 'gitlab' }
let!(:mr_source_branch) { 'a-branch' }
let!(:mr_labels) { ['backend', 'devops::create'] }
let!(:author) { Gitlab::Danger::Teammate.new('username' => 'johndoe') }
let!(:author) { Tooling::Danger::Teammate.new('username' => 'johndoe') }
let(:timezone_experiment) { false }
let(:spins) do
# Stub the request at the latest time so that we can modify the raw data, e.g. available fields.
......@@ -330,7 +330,7 @@ RSpec.describe Gitlab::Danger::Roulette do
describe '#spin_for_person' do
let(:person_tz_offset_hours) { 0.0 }
let(:person1) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'user1',
'available' => true,
'tz_offset_hours' => person_tz_offset_hours
......@@ -338,21 +338,21 @@ RSpec.describe Gitlab::Danger::Roulette do
end
let(:person2) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'user2',
'available' => true,
'tz_offset_hours' => person_tz_offset_hours)
end
let(:author) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'johndoe',
'available' => true,
'tz_offset_hours' => 0.0)
end
let(:unavailable) do
Gitlab::Danger::Teammate.new(
Tooling::Danger::Teammate.new(
'username' => 'janedoe',
'available' => false,
'tz_offset_hours' => 0.0)
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require_relative 'danger_spec_helper'
require 'gitlab/danger/sidekiq_queues'
require_relative '../../../tooling/danger/sidekiq_queues'
RSpec.describe Gitlab::Danger::SidekiqQueues do
RSpec.describe Tooling::Danger::SidekiqQueues do
using RSpec::Parameterized::TableSyntax
include DangerSpecHelper
......
# frozen_string_literal: true
require 'timecop'
require 'rspec-parameterized'
require 'gitlab/danger/teammate'
require_relative '../../../tooling/danger/teammate'
require 'active_support/testing/time_helpers'
RSpec.describe Gitlab::Danger::Teammate do
RSpec.describe Tooling::Danger::Teammate do
using RSpec::Parameterized::TableSyntax
subject { described_class.new(options) }
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require 'gitlab/danger/title_linting'
require_relative '../../../tooling/danger/title_linting'
RSpec.describe Gitlab::Danger::TitleLinting do
RSpec.describe Tooling::Danger::TitleLinting do
using RSpec::Parameterized::TableSyntax
describe '#sanitize_mr_title' do
......
# frozen_string_literal: true
require 'gitlab/danger/weightage/maintainers'
require_relative '../../../../tooling/danger/weightage/maintainers'
RSpec.describe Gitlab::Danger::Weightage::Maintainers do
let(:multiplier) { Gitlab::Danger::Weightage::CAPACITY_MULTIPLIER }
RSpec.describe Tooling::Danger::Weightage::Maintainers do
let(:multiplier) { Tooling::Danger::Weightage::CAPACITY_MULTIPLIER }
let(:regular_maintainer) { double('Teammate', reduced_capacity: false) }
let(:reduced_capacity_maintainer) { double('Teammate', reduced_capacity: true) }
let(:maintainers) do
......@@ -13,8 +13,8 @@ RSpec.describe Gitlab::Danger::Weightage::Maintainers do
]
end
let(:maintainer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier }
let(:reduced_capacity_maintainer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT }
let(:maintainer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier }
let(:reduced_capacity_maintainer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT }
subject(:weighted_maintainers) { described_class.new(maintainers).execute }
......
# frozen_string_literal: true
require 'gitlab/danger/weightage/reviewers'
require_relative '../../../../tooling/danger/weightage/reviewers'
RSpec.describe Gitlab::Danger::Weightage::Reviewers do
let(:multiplier) { Gitlab::Danger::Weightage::CAPACITY_MULTIPLIER }
RSpec.describe Tooling::Danger::Weightage::Reviewers do
let(:multiplier) { Tooling::Danger::Weightage::CAPACITY_MULTIPLIER }
let(:regular_reviewer) { double('Teammate', hungry: false, reduced_capacity: false) }
let(:hungry_reviewer) { double('Teammate', hungry: true, reduced_capacity: false) }
let(:reduced_capacity_reviewer) { double('Teammate', hungry: false, reduced_capacity: true) }
......@@ -26,11 +26,11 @@ RSpec.describe Gitlab::Danger::Weightage::Reviewers do
]
end
let(:hungry_reviewer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier + described_class::DEFAULT_REVIEWER_WEIGHT }
let(:hungry_reviewer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier + described_class::DEFAULT_REVIEWER_WEIGHT }
let(:hungry_traintainer_count) { described_class::TRAINTAINER_WEIGHT * multiplier + described_class::DEFAULT_REVIEWER_WEIGHT }
let(:reviewer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier }
let(:traintainer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT * described_class::TRAINTAINER_WEIGHT * multiplier }
let(:reduced_capacity_reviewer_count) { Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT }
let(:reviewer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT * multiplier }
let(:traintainer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT * described_class::TRAINTAINER_WEIGHT * multiplier }
let(:reduced_capacity_reviewer_count) { Tooling::Danger::Weightage::BASE_REVIEWER_WEIGHT }
let(:reduced_capacity_traintainer_count) { described_class::TRAINTAINER_WEIGHT }
subject(:weighted_reviewers) { described_class.new(reviewers, traintainers).execute }
......
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../tooling/gitlab_danger'
RSpec.describe GitlabDanger do
let(:gitlab_danger_helper) { nil }
......
......@@ -2,7 +2,7 @@
require_relative 'title_linting'
module Gitlab
module Tooling
module Danger
class BaseLinter
MIN_SUBJECT_WORDS_COUNT = 3
......
......@@ -2,7 +2,7 @@
require_relative 'title_linting'
module Gitlab
module Tooling
module Danger
module Changelog
NO_CHANGELOG_LABELS = [
......
# frozen_string_literal: true
emoji_checker_path = File.expand_path('emoji_checker', __dir__)
base_linter_path = File.expand_path('base_linter', __dir__)
if defined?(Rails)
require_dependency(base_linter_path)
require_dependency(emoji_checker_path)
else
require_relative(base_linter_path)
require_relative(emoji_checker_path)
end
require_relative 'base_linter'
require_relative 'emoji_checker'
module Gitlab
module Tooling
module Danger
class CommitLinter < BaseLinter
MAX_CHANGED_FILES_IN_COMMIT = 3
......@@ -151,7 +143,7 @@ module Gitlab
end
def emoji_checker
@emoji_checker ||= Gitlab::Danger::EmojiChecker.new
@emoji_checker ||= Tooling::Danger::EmojiChecker.new
end
end
end
......
......@@ -2,11 +2,11 @@
require 'json'
module Gitlab
module Tooling
module Danger
class EmojiChecker
DIGESTS = File.expand_path('../../../fixtures/emojis/digests.json', __dir__)
ALIASES = File.expand_path('../../../fixtures/emojis/aliases.json', __dir__)
DIGESTS = File.expand_path('../../fixtures/emojis/digests.json', __dir__)
ALIASES = File.expand_path('../../fixtures/emojis/aliases.json', __dir__)
# A regex that indicates a piece of text _might_ include an Emoji. The regex
# alone is not enough, as we'd match `:foo:bar:baz`. Instead, we use this
......
......@@ -3,7 +3,7 @@
require_relative 'teammate'
require_relative 'title_linting'
module Gitlab
module Tooling
module Danger
module Helper
RELEASE_TOOLS_BOT = 'gitlab-release-tools-bot'
......@@ -171,7 +171,7 @@ module Gitlab
%r{\Alefthook.yml\z} => :engineering_productivity,
%r{\A\.editorconfig\z} => :engineering_productivity,
%r{Dangerfile\z} => :engineering_productivity,
%r{\A(ee/)?(danger/|lib/gitlab/danger/)} => :engineering_productivity,
%r{\A(ee/)?(danger/|tooling/danger/)} => :engineering_productivity,
%r{\A(ee/)?scripts/} => :engineering_productivity,
%r{\Atooling/} => :engineering_productivity,
%r{(CODEOWNERS)} => :engineering_productivity,
......@@ -213,7 +213,7 @@ module Gitlab
}.freeze
def new_teammates(usernames)
usernames.map { |u| Gitlab::Danger::Teammate.new('username' => u) }
usernames.map { |u| Tooling::Danger::Teammate.new('username' => u) }
end
def draft_mr?
......
# frozen_string_literal: true
base_linter_path = File.expand_path('base_linter', __dir__)
require_relative 'base_linter'
if defined?(Rails)
require_dependency(base_linter_path)
else
require_relative(base_linter_path)
end
module Gitlab
module Tooling
module Danger
class MergeRequestLinter < BaseLinter
alias_method :lint, :lint_subject
......
......@@ -3,7 +3,7 @@
require 'net/http'
require 'json'
module Gitlab
module Tooling
module Danger
module RequestHelper
HTTPError = Class.new(RuntimeError)
......
# frozen_string_literal: true
require_relative 'teammate'
require_relative 'request_helper' unless defined?(Gitlab::Danger::RequestHelper)
require_relative 'request_helper'
require_relative 'weightage/reviewers'
require_relative 'weightage/maintainers'
module Gitlab
module Tooling
module Danger
module Roulette
ROULETTE_DATA_URL = 'https://gitlab-org.gitlab.io/gitlab-roulette/roulette.json'
......@@ -72,8 +72,8 @@ module Gitlab
def team
@team ||=
begin
data = Gitlab::Danger::RequestHelper.http_get_json(ROULETTE_DATA_URL)
data.map { |hash| ::Gitlab::Danger::Teammate.new(hash) }
data = Tooling::Danger::RequestHelper.http_get_json(ROULETTE_DATA_URL)
data.map { |hash| ::Tooling::Danger::Teammate.new(hash) }
rescue JSON::ParserError
raise "Failed to parse JSON response from #{ROULETTE_DATA_URL}"
end
......
# frozen_string_literal: true
module Gitlab
module Tooling
module Danger
module SidekiqQueues
def changed_queue_files
......
# frozen_string_literal: true
module Gitlab
module Tooling
module Danger
class Teammate
attr_reader :options, :username, :name, :role, :projects, :available, :hungry, :reduced_capacity, :tz_offset_hours
......
# frozen_string_literal: true
module Gitlab
module Tooling
module Danger
module TitleLinting
DRAFT_REGEX = /\A*#{Regexp.union(/(?i)(\[WIP\]\s*|WIP:\s*|WIP$)/, /(?i)(\[draft\]|\(draft\)|draft:|draft\s\-\s|draft$)/)}+\s*/i.freeze
......
# frozen_string_literal: true
module Gitlab
module Tooling
module Danger
module Weightage
CAPACITY_MULTIPLIER = 2 # change this number to change what it means to be a reduced capacity reviewer 1/this number
......
......@@ -2,7 +2,7 @@
require_relative '../weightage'
module Gitlab
module Tooling
module Danger
module Weightage
class Maintainers
......
......@@ -2,7 +2,7 @@
require_relative '../weightage'
module Gitlab
module Tooling
module Danger
module Weightage
# Weights after (current multiplier of 2)
......
# frozen_string_literal: true
# rubocop:todo Gitlab/NamespacedClass
class GitlabDanger
LOCAL_RULES ||= %w[
changes_size
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment