DFE-Digital / DFE-Digital/dfe-analytics

`ServicePattern` pollutes the top-level namespace

Open
#136 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
12
Forks
9
Avg merge
3d 15h
Merged PRs (30d)
4

Description

The ServicePattern module is defined as a top-level module, rather than being namespaced within the DfE::Analytics module. It therefore pollutes the top-level namespace of any Ruby app which uses the dfe-analytics gem.

https://github.com/DFE-Digital/dfe-analytics/blob/3e078f9fdd0e890449f90e7cd2f151c392d570ac/lib/dfe/analytics/shared/service_pattern.rb#L1-L8

For example, this caused some strange behaviour over in https://github.com/DFE-Digital/itt-mentor-services/pull/521#discussion_r1578212067 where we had to manually require our own ServicePattern module directly in a spec file to override the one provided by dfe-analytics.

I think ideally this module should be namespaced inside DfE::Analytics to avoid this from happening – plus to be consistent with the other classes in this gem, which all seem to be namespaced according to their file path.

In other words, I think lib/dfe/analytics/shared/service_pattern.rb should be changed to:

# a template for creating service objects
module DfE
  module Analytics
    module Shared
      module ServicePattern
        # ...
      end
    end
  end
end

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/dfe/analytics/shared/service_pattern.rb and inspect references to ServicePattern across the gem. Confirm how callers load the module, then verify that it is available under the intended DfE::Analytics namespace without polluting the top-level namespace.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.