Skip to content

Fix top 3 Ruby runtime warnings

Peter Leitzen requested to merge pl-fix-top-runtime-warnings into master

What does this MR do?

This MR fixes the top 3 Ruby warnings when running specs with --warnings enabled:

rspec --exclude-pattern 'spec/features/**/*,ee/spec/features/**/*' --warnings > warnings.txt

These are:

1938576 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/declarative_policy/runner.rb:42: warning: instance variable @state not initialized
 962808 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/marginalia.rb:18: warning: instance variable @enabled not initialized
  63669 /home/peter/devel/gitlab/gdk-ee/gitlab/ee/app/models/ee/namespace.rb:332: warning: instance variable @plan_name not initialized
Top 30
cat warnings.txt | sort -g | uniq -c | sort -rn  | grep "gdk-ee" | head -30

1938576 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/declarative_policy/runner.rb:42: warning: instance variable @state not initialized
 962808 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/marginalia.rb:18: warning: instance variable @enabled not initialized
  63669 /home/peter/devel/gitlab/gdk-ee/gitlab/ee/app/models/ee/namespace.rb:332: warning: instance variable @plan_name not initialized
  27083 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/config/entry/node.rb:51: warning: instance variable @parent not initialized
  13341 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/ci/ansi2json/line.rb:92: warning: instance variable @section_duration not initialized
   6118 /home/peter/devel/gitlab/gdk-ee/gitlab/app/models/concerns/atomic_internal_id.rb:60: warning: instance variable @internal_id_needs_tracking not initialized
   4348 /home/peter/devel/gitlab/gdk-ee/gitlab/app/models/internal_id.rb:200: warning: although a splat keyword arguments here
   2734 /home/peter/devel/gitlab/gdk-ee/gitlab/app/models/merge_request.rb:607: warning: instance variable @source_branch_sha not initialized
   2318 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/config/loader/yaml.rb:15: Passing permitted_symbols with the 3rd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_symbols: ...) instead.
   2318 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/config/loader/yaml.rb:15: Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead.
   2318 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/config/loader/yaml.rb:15: Passing aliases with the 4th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, aliases: ...) instead.
   2012 /home/peter/devel/gitlab/gdk-ee/gitlab/app/models/merge_request.rb:644: warning: instance variable @target_branch_sha not initialized
   1598 /home/peter/devel/gitlab/gdk-ee/gitlab/app/controllers/projects/application_controller.rb:23: warning: instance variable @project not initialized
   1415 /home/peter/devel/gitlab/gdk-ee/gitlab/app/models/merge_request.rb:614: warning: instance variable @target_branch_sha not initialized
   1394 /home/peter/devel/gitlab/gdk-ee/gitlab/app/models/merge_request.rb:648: warning: instance variable @source_branch_sha not initialized
   1335 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/cache/request_cache.rb:37: warning: instance variable @cache_protected☆ not initialized
   1295 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/cache/request_cache.rb:37: warning: instance variable @cache_can_push_to_branch☆ not initialized
   1125 /home/peter/devel/gitlab/gdk-ee/gitlab/ee/lib/ee/gitlab/auth/auth_finders.rb:25: warning: instance variable @current_authenticated_job not initialized
    954 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/graphql/present.rb:13: warning: instance variable @presenter_class not initialized
    932 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/config/entry/node.rb:46: warning: instance variable @parent not initialized
    830 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/git/diff_collection.rb:103: warning: instance variable @populated not initialized
    784 /home/peter/devel/gitlab/gdk-ee/gitlab/app/controllers/application_controller.rb:472: warning: URI.escape is obsolete
    541 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/ci/ansi2json/line.rb:60: warning: instance variable @section_duration not initialized
    533 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/config/entry/node.rb:84: warning: instance variable @key not initialized
    498 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/cache/request_cache.rb:37: warning: instance variable @cache_author not initialized
    371 /home/peter/devel/gitlab/gdk-ee/gitlab/app/models/concerns/noteable.rb:27: warning: instance variable @system_note_timestamp not initialized
    297 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/pagination/offset_pagination.rb:90: warning: although a splat keyword arguments here
    251 /home/peter/devel/gitlab/gdk-ee/gitlab/app/helpers/page_layout_helper.rb:38: warning: instance variable @page_description not initialized
    210 /home/peter/devel/gitlab/gdk-ee/gitlab/lib/gitlab/git/repository.rb:701: warning: instance variable @info_attributes not initialized
    199 /home/peter/devel/gitlab/gdk-ee/gitlab/app/helpers/application_helper.rb:201: warning: instance variable @snippet not initialized

Please see individual commit messages and notes from self-review for some quirks.

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 Peter Leitzen

Merge request reports