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

Fixed warnings due to uninitialized instance variable #836

Closed

Conversation

nitinsingh25
Copy link

I have fixed following two warnings:

  1. lib/apipie/param_description.rb:103: warning: instance variable @from_concern not initialized
  2. lib/apipie/dsl_definition.rb:349: warning: instance variable @_current_param_group not initialized

@@ -101,7 +101,7 @@ def initialize(method_description, name, validator, desc_or_options = nil, optio
end

def from_concern?
method_description.from_concern? || @from_concern
method_description.from_concern? || (defined?(@from_concern) && @from_concern)
Copy link
Contributor

@PanosCodes PanosCodes Mar 3, 2023

Choose a reason for hiding this comment

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

I think for this case we can leave it as is

Suggested change
method_description.from_concern? || (defined?(@from_concern) && @from_concern)
method_description.from_concern? || @from_concern

and update lines

if @options[:param_group]
@from_concern = @options[:param_group][:from_concern]
end

from

if @options[:param_group]
  @from_concern = @options[:param_group][:from_concern]
end

to

@from_concern = @options.dig(:param_group, :from_concern)

Copy link
Collaborator

@mathieujobin mathieujobin left a comment

Choose a reason for hiding this comment

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

I don't think adding a check on usage is the right way. just making sure it gets initialize on object creation is probably more desirable

Thanks for taking a stab at it though.

What do you think of #838 ?

@nitinsingh25
Copy link
Author

I don't think adding a check on usage is the right way. just making sure it gets initialize on object creation is probably more desirable

Thanks for taking a stab at it though.

What do you think of #838 ?

Yup, changes of #838 seems more appropriate. Let me test my changes with #838.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants