exAspArk / graphql-guard

Simple authorization gem for GraphQL :lock:
MIT License
472 stars 36 forks source link

Missing magic comment `# frozen_string_literal: true` and "Freeze mutable objects assigned to constants.". #9

Closed ghost closed 6 years ago

ghost commented 6 years ago

I have this graphql_policy.rb:

class GraphqlPolicy
  RULES = {

    Types::QueryType => {
      '*': ->(_obj, _args, ctx) { ctx[:current_user] }
    }
  }

  def self.guard(type, field)
    RULES.dig(type, field)
  end
end

Now using rubocop on it I got this:

image

What we can do?

ghost commented 6 years ago

Maybe RULES.freeze = {?

exAspArk commented 6 years ago

@johnunclesam the issue doesn't seem to be related to the gem. You or your IDE is using https://github.com/bbatsov/rubocop which checks the syntax of your code.