summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2018-01-23 18:42:10 +0100
committerJacob Vosmaer <jacob@gitlab.com>2018-01-25 14:05:11 +0100
commit6d6f7536bd9b5bcbf94dfbe15cc86e84d06527f5 (patch)
tree6b6c62e084b1ce914da742be847d56086b0b6475 /scripts
parent1f5af51b476a36a72759e7560c125c2b9602b145 (diff)
downloadgitlab-ce-6d6f7536bd9b5bcbf94dfbe15cc86e84d06527f5.tar.gz
Look for rugged with static analysislint-rugged
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/lint-rugged36
-rwxr-xr-xscripts/static-analysis3
2 files changed, 38 insertions, 1 deletions
diff --git a/scripts/lint-rugged b/scripts/lint-rugged
new file mode 100755
index 00000000000..3f8fcb558e3
--- /dev/null
+++ b/scripts/lint-rugged
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+
+ALLOWED = [
+ # Can be deleted (?) once rugged is no longer used in production. Doesn't make Rugged calls.
+ 'config/initializers/8_metrics.rb',
+
+ # Can be deleted once wiki's are fully (mandatory) migrated
+ 'config/initializers/gollum.rb',
+
+ # Needs to be migrated, https://gitlab.com/gitlab-org/gitaly/issues/953
+ 'lib/gitlab/bare_repository_import/repository.rb',
+
+ # Needs to be migrated, https://gitlab.com/gitlab-org/gitaly/issues/954
+ 'lib/tasks/gitlab/cleanup.rake',
+
+ # https://gitlab.com/gitlab-org/gitaly/issues/961
+ 'app/models/repository.rb',
+
+ # The only place where Rugged code is still allowed in production
+ 'lib/gitlab/git/'
+].freeze
+
+rugged_lines = IO.popen(%w[git grep -i -n rugged -- app config lib], &:read).lines
+rugged_lines = rugged_lines.reject { |l| l.start_with?(*ALLOWED) }
+rugged_lines = rugged_lines.reject do |line|
+ code, _comment = line.split('# ', 2)
+ code !~ /rugged/i
+end
+
+exit if rugged_lines.empty?
+
+puts "Using Rugged is only allowed in test and #{ALLOWED}\n\n"
+
+puts rugged_lines
+
+exit(false)
diff --git a/scripts/static-analysis b/scripts/static-analysis
index 9690b42c788..96d08287ded 100755
--- a/scripts/static-analysis
+++ b/scripts/static-analysis
@@ -13,7 +13,8 @@ tasks = [
%w[bundle exec rake gettext:lint],
%w[bundle exec rake lint:static_verification],
%w[scripts/lint-changelog-yaml],
- %w[scripts/lint-conflicts.sh]
+ %w[scripts/lint-conflicts.sh],
+ %w[scripts/lint-rugged]
]
failed_tasks = tasks.reduce({}) do |failures, task|