-
Notifications
You must be signed in to change notification settings - Fork 7
Clean up client.rb #24
base: master
Are you sure you want to change the base?
Conversation
| item.set('Boolean', true) | ||
| item.set('Array', [i, i * 2, i * 3, 'Orange', 'Tomato']) | ||
| item.set('Object', {test1: 'a', test2: 'b'}) | ||
| item.set('Object', { test1: 'a', test2: 'b' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Redundant curly braces around a hash parameter.
| # @todo = @todo.limit(20).inArray("Array", [4]) | ||
| # @todo = @todo.limit(20).notInArray("Array", ['Orange']) | ||
| # @todo = @todo.limit(20).allInArray("Array", [1, 2, 4]) | ||
| =begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # @todo = @todo.limit(20).notInArray("Array", ['Orange']) | ||
| # @todo = @todo.limit(20).allInArray("Array", [1, 2, 4]) | ||
| =begin | ||
| @todo = @todo.limit(20).where("String", 'テスト100').greaterThan("Integer", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Use only ascii symbols in comments. :ref
| # @todo = @todo.limit(20).allInArray("Array", [1, 2, 4]) | ||
| =begin | ||
| @todo = @todo.limit(20).where("String", 'テスト100').greaterThan("Integer", 1) | ||
| @todo = @todo.limit(20).notEqualTo("String", 'テスト100') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Use only ascii symbols in comments. :ref
| =begin | ||
| @todo = @todo.limit(20).where("String", 'テスト100').greaterThan("Integer", 1) | ||
| @todo = @todo.limit(20).notEqualTo("String", 'テスト100') | ||
| @todo = @todo.limit(20).in("String", ['テスト100']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Use only ascii symbols in comments. :ref
| testKey: 'testValue' | ||
| } | ||
| } | ||
| { where: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Redundant curly braces around a hash parameter.
| } | ||
| { where: { | ||
| testKey: 'testValue' | ||
| }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Space inside } missing. :ref
| item.set('Boolean', true) | ||
| item.set('Array', [i, i * 2, i * 3, 'Orange', 'Tomato']) | ||
| item.set('Object', {test1: 'a', test2: 'b'}) | ||
| item.set('Object', { test1: 'a', test2: 'b' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Redundant curly braces around a hash parameter.
|
|
||
| def deletable? | ||
| if self.acl['*'.to_sym][:write] == true | ||
| if acl['*'.to_sym][:write] == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Favor modifier
ifusage when having a single-line body. Another good alternative is the usage of control flow&&/||. :ref
| end | ||
| alias :update :put | ||
| alias update put |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Use a guard clause instead of wrapping the code inside a conditional expression. :ref
lib/ncmb/client.rb
Outdated
| queries.each do |k, v| | ||
| v = array2hash(v) if v.is_a? Array | ||
| value = URI.encode(v.is_a?(Hash) ? v.to_json : v.to_s).gsub("[", "%5B").gsub(":", "%3A").gsub("]", "%5D") | ||
| value = URI.encode(v.is_a?(Hash) ? v.to_json : v.to_s).gsub('[', '%5B').gsub(':', '%3A').gsub(']', '%5D') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Line is too long. [113/80] :ref
lib/ncmb/client.rb
Outdated
| signature_base << @domain | ||
| signature_base << path | ||
| signature_base << params.collect{|k,v| "#{k}=#{v}"}.join("&") | ||
| signature_base << params.collect{|k,v| "#{k}=#{v}"}.join('&') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Space missing to the left of {.
- Space between { and | missing.
- Space missing after comma. :ref
- Space missing inside }.
lib/ncmb/client.rb
Outdated
| "#{key}=#{value}" | ||
| end.join("&") | ||
| path = path + (query == '' ? "" : "?"+query) | ||
| path = path + (query == '' ? '' : "?"+query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/ncmb/client.rb
Outdated
| boundary = SecureRandom.uuid | ||
| req.body = make_boundary(boundary, queries) | ||
| headers["Content-Type"] = "multipart/form-data; boundary=#{boundary}" | ||
| headers['Content-Type'] = "multipart/form-data; boundary=#{boundary}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Line is too long. [81/80] :ref
lib/ncmb/client.rb
Outdated
| boundary = SecureRandom.uuid | ||
| req.body = make_boundary(boundary, queries) | ||
| headers["Content-Type"] = "multipart/form-data; boundary=#{boundary}" | ||
| headers['Content-Type'] = "multipart/form-data; boundary=#{boundary}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Line is too long. [81/80] :ref
| end | ||
| end | ||
| new_v = new_v.sort_by{|a, b| a.to_s}.to_h | ||
| new_v = new_v.sort_by{ |a, b| a.to_s }.to_h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Space missing to the left of {.
- Unused block argument -
b. If it's necessary, use_or_bas an argument name to indicate that it won't be used. :ref
| v = array2hash(v) if v.is_a? Array | ||
| value = URI.encode(v.is_a?(Hash) ? v.to_json : v.to_s).gsub("[", "%5B").gsub(":", "%3A").gsub("]", "%5D") | ||
| value = URI.encode(v.is_a?(Hash) ? v.to_json : v.to_s) | ||
| .encode("UTF-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Align
.encodewith.encodeon line 63. - Prefer single-quoted strings when you don't need string interpolation or special symbols. :ref
| value = URI.encode(v.is_a?(Hash) ? v.to_json : v.to_s).gsub("[", "%5B").gsub(":", "%3A").gsub("]", "%5D") | ||
| value = URI.encode(v.is_a?(Hash) ? v.to_json : v.to_s) | ||
| .encode("UTF-8") | ||
| .gsub('[', '%5B') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Align
.gsubwith.encodeon line 63.
| value = URI.encode(v.is_a?(Hash) ? v.to_json : v.to_s) | ||
| .encode("UTF-8") | ||
| .gsub('[', '%5B') | ||
| .gsub(':', '%3A') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Align
.gsubwith.encodeon line 63.
| .encode("UTF-8") | ||
| .gsub('[', '%5B') | ||
| .gsub(':', '%3A') | ||
| .gsub(']', '%5D') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Align
.gsubwith.encodeon line 63.
| params = params.sort_by{|a, b| a.to_s}.to_h | ||
| params = params.merge 'X-NCMB-Timestamp' => now | ||
| if [].respond_to?('to_h') # Array#to_h inpremented over ruby 2.1 | ||
| params = params.sort_by { |a, b| a.to_s }.to_h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Unused block argument -
b. If it's necessary, use_or_bas an argument name to indicate that it won't be used. :ref
| else | ||
| sorted_params = {} | ||
| params = params.sort_by{|a, b| a.to_s}.each {|kv| | ||
| params = params.sort_by { |a, b| a.to_s }.each { |kv| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| signature_base << params.collect { |k, v| "#{k}=#{v}" }.join('&') | ||
| Base64.encode64( | ||
| OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), | ||
| @client_key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Align the parameters of a method call if they span more than one line. :ref
| Base64.encode64( | ||
| OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), | ||
| @client_key, | ||
| signature_base.join("\n")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Align the parameters of a method call if they span more than one line. :ref
|
Click here if you want to create rubocop's auto-correct Pull Request See the documentation if you want to get more information about auto-correct. |
| json = http.get(path, headers).body | ||
| else | ||
| json = JSON.parse(http.get(path, headers).body, symbolize_names: true) | ||
| json = JSON.parse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Use 2 (not -5) spaces for indentation. :ref
| end | ||
| rescue => e | ||
| @@last_error = e | ||
| @@last_error = e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop]
- Replace class var @@last_error with a class instance var. :ref

No description provided.