Skip to content

Add Rubocop configuration #130

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

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

Conversation

bastelfreak
Copy link
Collaborator

Summary

Provide a detailed description of all the changes present in this pull request.

Additional Context

Add any additional context about the problem here.

  • Root cause and the steps to reproduce. (If applicable)
  • Thought process behind the implementation.

Related Issues (if any)

Mention any related issues or pull requests.

@bastelfreak bastelfreak self-assigned this Apr 9, 2025
@bastelfreak bastelfreak requested a review from a team as a code owner April 9, 2025 10:54
Copy link
Contributor

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Just some things that jumped out to me.

Comment on lines +15 to +19
class_name = if is_a? Class
name
else
self.class.name
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps even reduce it to a ternary

Suggested change
class_name = if is_a? Class
name
else
self.class.name
end
class_name = is_a?(Class) ? name : self.class.name

if path !~ /\A#{Regexp.escape destdir}/
raise PuppetForge::InvalidPathInPackageError, :entry_path => path, :directory => destdir
end
return if /\A#{Regexp.escape destdir}/.match?(path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this equal to

Suggested change
return if /\A#{Regexp.escape destdir}/.match?(path)
return path.start_with?(destdir)

@@ -22,10 +21,10 @@ def initialize(json_response)
end

def orm_resp_item(json_response)
json_response.each do |key, value|
json_response.each do |key, _value|
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
json_response.each do |key, _value|
json_response.each_key do |key|

Comment on lines +157 to 158
param_hash = {}
params.each do |param|
Copy link
Contributor

Choose a reason for hiding this comment

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

This could also be

param_hash = params.to_h { |param| param.split('=') }


def to_json
def to_json(*_args)
data = @data.dup.merge('dependencies' => dependencies)

contents = data.keys.map do |k|
Copy link
Contributor

Choose a reason for hiding this comment

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

I think rubocop-performance should catch this and iterate on the pair

Suggested change
contents = data.keys.map do |k|
contents = data.map do |k, v|

else
source_uri = URI.parse("http://#{data['source']}")
end
source_uri = if %r{://}.match?(data['source'])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
source_uri = if %r{://}.match?(data['source'])
source_uri = data['source']&.include?('://')

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

Successfully merging this pull request may close these issues.

2 participants