Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rubocop Lint/DuplicateMethods #12350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anansilva
Copy link
Collaborator

What? Why?

  • Part of Fix Rubocop Lint issues #12330

Fixed the Lint/DuplicateMethods offense.

sso_secret is defined at both attr_accessor and lib/discourse/single_sign_on.rb:66

sso_url is defined at both attr_accessor and lib/discourse/single_sign_on.rb:70

What should we test?

Fix seems pretty safe since we are just removing duplicate instance methods. But might be worth testing SSO to discourse.

Release notes

Changelog Category: Technical changes

Dependencies

Documentation updates

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @anansilva ! It looks good 👍

@rioug rioug added the technical changes only These pull requests do not contain user facing changes and are grouped in release notes label Apr 9, 2024
@sigmundpetersen sigmundpetersen mentioned this pull request Apr 9, 2024
14 tasks
Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might actually break things, which are not tested.
But before we proceed any further, I'll try to find out if it's even used...

I've posted in #delivery-circle, so let's pause until we can resolve that question.

Comment on lines -15 to 18
attr_accessor(*ACCESSORS, :sso_secret, :sso_url)
attr_accessor(*ACCESSORS)

def self.sso_secret
raise "sso_secret not implemented on class, be sure to set it on instance"
Copy link
Member

@dacook dacook Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't see the instance method declared elsewhere, so I wonder if it's confused the class method as a duplicate.
Sorry I didn't read the PR description properly, I now understand!

I can't actually find any specs covering this, so I tried constructing a quick test in the console:

require 'discourse/single_sign_on'
sso = Discourse::SingleSignOn.parse("query_string", "secret")
NoMethodError: undefined method `sso_secret=' for #<Discourse::SingleSignOn:0x0000000114c12798>

      sso.sso_secret = sso_secret if sso_secret
         ^^^^^^^^^^^^^
Did you mean?  sso_secret

So it's relying on attr_accessor to implement the setter method.

This is obviously not an exhaustive test, so we should either add specs, or definitely do a manual test of the functionality. Hmm, but I can't find any documentation about this.. I wonder if it's even used...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

± To fix: the class methods (self.sso_secret etc) seem unnecessary, so I'd consider removing them instead. And why not move :sso_secret, :sso_url to the ACCESSORS list..

But still I'd like to confirm if it's worth it first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: this whole file is unused and so I've scheduled for removal.

For now, I suggest we add rubocop:disable for this whole file and move on.

Comment on lines -15 to 18
attr_accessor(*ACCESSORS, :sso_secret, :sso_url)
attr_accessor(*ACCESSORS)

def self.sso_secret
raise "sso_secret not implemented on class, be sure to set it on instance"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: this whole file is unused and so I've scheduled for removal.

For now, I suggest we add rubocop:disable for this whole file and move on.

@sigmundpetersen
Copy link
Contributor

Hey @anansilva 👋 Do you want to continue this?
Note that Discourse SSO was removed in #12496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical changes only These pull requests do not contain user facing changes and are grouped in release notes
Projects
Status: In Progress ⚙
Development

Successfully merging this pull request may close these issues.

None yet

4 participants