Permalink
Browse files

Add rubocop to the codebase

  • Loading branch information...
rhymes committed Mar 8, 2016
1 parent 3c2be9c commit d5d943333de497ef0ae2da729fc6ec838a9eb801
View
@@ -6,6 +6,30 @@ AllCops:
- 'parse-ruby-client.gemspec'
DisplayCopNames: true
DisplayStyleGuide: true
ExtraDetails: true
TargetRubyVersion: 1.9
Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent
Style/Alias:
EnforcedStyle: prefer_alias
Style/FileName:
Exclude:
- 'lib/parse-ruby-client.rb'
Style/AutoResourceCleanup:
Enabled: true
Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent
Style/CollectionMethods:
Enabled: true
Style/Encoding:
Enabled: true
Style/MultilineMethodCallIndentation:
EnforcedStyle: indented
View
@@ -1,55 +1,51 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-07-17 16:22:15 +0200 using RuboCop version 0.32.1.
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-03-08 22:23:30 +0100 using RuboCop version 0.37.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
Lint/UselessComparison:
Enabled: false
# Offense count: 35
# Offense count: 27
Metrics/AbcSize:
Max: 35
# Offense count: 9
# Offense count: 10
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 293
# Offense count: 8
Metrics/CyclomaticComplexity:
Max: 10
Max: 12
# Offense count: 89
# Configuration parameters: AllowURI, URISchemes.
# Offense count: 85
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 167
# Offense count: 58
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 26
Max: 29
# Offense count: 6
# Offense count: 7
Metrics/PerceivedComplexity:
Max: 12
# Offense count: 3
Style/ClassVars:
Enabled: false
# Offense count: 38
Style/Documentation:
Enabled: false
# Offense count: 1
# Configuration parameters: Exclude.
Style/FileName:
Enabled: false
# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
Exclude:
- 'lib/parse/client.rb'
- 'test/helper.rb'
# Offense count: 43
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'lib/parse/client.rb'
- 'lib/parse/installation.rb'
- 'lib/parse/protocol.rb'
- 'lib/parse/version.rb'
- 'test/test_query.rb'
View
@@ -1,6 +1,6 @@
# encoding: utf-8
require "bundler/gem_tasks"
require "rake/testtask"
require 'bundler/gem_tasks'
require 'rake/testtask'
task default: :test
View
@@ -1,4 +1,4 @@
# -*- encoding : utf-8 -*-
# encoding: utf-8
client = Parse.create(
application_id: 'your_application_id',
api_key: 'your_REST_API_Key')
@@ -1,3 +1,4 @@
# encoding: utf-8
module Faraday
# Custom version of Request::Retry with two additions:
# 1 - logs (on warn level) each retry attempt
@@ -13,11 +14,9 @@ def initialize(app, options = nil)
@options.methods << :post
# NOTE: the default exceptions are lost when custom ones are given
@options.exceptions.concat([
Errno::ETIMEDOUT,
'Timeout::Error',
Error::TimeoutError
])
default_exceptions = [
Errno::ETIMEDOUT, 'Timeout::Error', Error::TimeoutError]
@options.exceptions.concat(default_exceptions)
end
def call(env)
@@ -1,5 +1,6 @@
# -*- encoding : utf-8 -*-
# encoding: utf-8
module Faraday
# A middleware to display error messages in the JSON response
class ExtendedParseJson < FaradayMiddleware::ParseJson
def process_response(env)
env[:raw_body] = env[:body] if preserve_raw?(env)
@@ -16,17 +17,19 @@ def process_response(env)
Parse::Protocol::ERROR_TIMEOUT,
Parse::Protocol::ERROR_EXCEEDED_BURST_LIMIT
]
error_hash = { 'error' => "HTTP Status #{env[:status]} Body #{env[:body]}", 'http_status_code' => env[:status] }.merge(data)
error_hash = {
'error' => "HTTP Status #{env[:status]} Body #{env[:body]}",
'http_status_code' => env[:status]
}.merge(data)
if data['code'] && array_codes.include?(data['code'])
sleep 60 if data['code'] == Parse::Protocol::ERROR_EXCEEDED_BURST_LIMIT
fail exception(env), error_hash.merge(data)
raise exception(env), error_hash.merge(data)
elsif env[:status] >= 500
fail exception(env), error_hash.merge(data)
raise exception(env), error_hash.merge(data)
end
fail Parse::ParseProtocolError, error_hash
raise Parse::ParseProtocolError, error_hash
else
data = parse(env[:body]) || {}
env[:body] = data
end
end
@@ -1,5 +1,4 @@
# -*- encoding : utf-8 -*-
# encoding: utf-8
require 'faraday'
module Faraday
View
@@ -1,9 +1,9 @@
# -*- encoding : utf-8 -*-
# encoding: utf-8
## ----------------------------------------------------------------------
##
## Ruby client for parse.com
## A quick library for playing with parse.com's REST API for object storage.
## See https://parse.com/docs/rest for full documentation on the API.
## See https://parse.com/docs/rest/guide/ for full documentation on the API.
##
## ----------------------------------------------------------------------
require 'rubygems'
View
@@ -1,4 +1,7 @@
# encoding: utf-8
module Parse
# Parse Application
# https://parse.com/docs/rest/guide/#config
class Application
def self.config(client = nil)
client ||= Parse.client
View
@@ -1,5 +1,7 @@
# -*- encoding : utf-8 -*-
# encoding: utf-8
module Parse
# Issue batch operations
# https://parse.com/docs/rest/guide/#objects-batch-operations
class Batch
attr_reader :requests
attr_accessor :client
View
@@ -1,13 +1,13 @@
# -*- encoding : utf-8 -*-
# encoding: utf-8
require 'parse/protocol'
require 'parse/error'
require 'parse/util'
require 'logger'
# This module contains all the code
module Parse
# A class which encapsulates the HTTPS communication with the Parse
# API server.
# The client that communicates with the Parse server via REST
class Client
RETRIED_EXCEPTIONS = [
'Faraday::Error::TimeoutError',
@@ -196,7 +196,7 @@ def destroy
end
def client
fail ParseError, 'API not initialized' unless @@client
raise ParseError, 'API not initialized' unless @@client
@@client
end
View
@@ -1,6 +1,8 @@
# -*- encoding : utf-8 -*-
# encoding: utf-8
module Parse
module Cloud
# Call cloud functions
# https://parse.com/docs/rest/guide/#cloud-code-cloud-functions
class Function
attr_accessor :function_name
attr_accessor :client
Oops, something went wrong.

0 comments on commit d5d9433

Please sign in to comment.