Skip to content

Commit

Permalink
Autocorrect StringLiterals offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Nov 26, 2014
1 parent 92aaf57 commit e79b14b
Show file tree
Hide file tree
Showing 120 changed files with 2,944 additions and 2,950 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Expand Up @@ -27,9 +27,3 @@ Metrics/MethodLength:
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false

# Offense count: 3235
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
Enabled: false
4 changes: 2 additions & 2 deletions Gemfile
@@ -1,9 +1,9 @@
source "https://rubygems.org"
source 'https://rubygems.org'

# The gem's dependencies are specified in gir_ffi.gemspec
gemspec

if ENV["CI"]
if ENV['CI']
gem 'coveralls', type: :development, platform: :mri
else
gem 'simplecov', '~> 0.9.0', type: :development, platform: :mri
Expand Down
2 changes: 1 addition & 1 deletion lib/ffi-glib/array.rb
Expand Up @@ -77,7 +77,7 @@ def calculated_element_size

def check_element_size_match
unless calculated_element_size == get_element_size
warn "WARNING: Element sizes do not match"
warn 'WARNING: Element sizes do not match'
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ffi-glib/error.rb
Expand Up @@ -4,7 +4,7 @@ module GLib
# Overrides for GError, used by GLib for handling non-fatal errors.
class Error
# TODO: Auto-convert strings and symbols to quarks
GIR_FFI_DOMAIN = GLib.quark_from_string("gir_ffi")
GIR_FFI_DOMAIN = GLib.quark_from_string('gir_ffi')

def self.from_exception ex
new_literal GIR_FFI_DOMAIN, 0, ex.message
Expand Down
4 changes: 2 additions & 2 deletions lib/ffi-glib/hash_table.rb
Expand Up @@ -56,7 +56,7 @@ def self.hash_function_for keytype
when :utf8
FFI::Function.new(:uint,
[:pointer],
find_support_function("g_str_hash"))
find_support_function('g_str_hash'))
else
nil
end
Expand All @@ -67,7 +67,7 @@ def self.equality_function_for keytype
when :utf8
FFI::Function.new(:int,
[:pointer, :pointer],
find_support_function("g_str_equal"))
find_support_function('g_str_equal'))
else
nil
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ffi-glib/variant.rb
Expand Up @@ -3,7 +3,7 @@
module GLib
# Overrides for GVariant, GLib's variant data type.
class Variant
setup_instance_method "get_string"
setup_instance_method 'get_string'

def get_string_with_override
get_string_without_override.first
Expand Down
2 changes: 1 addition & 1 deletion lib/ffi-gobject.rb
Expand Up @@ -55,7 +55,7 @@ def self.signal_emit object, detailed_signal, *args
end

def self.signal_connect object, detailed_signal, data = nil, &block
raise ArgumentError, "Block needed" unless block_given?
raise ArgumentError, 'Block needed' unless block_given?
signal_name, _ = detailed_signal.split('::')
sig_info = object.class.find_signal signal_name

Expand Down
46 changes: 23 additions & 23 deletions lib/ffi-gobject/base.rb
@@ -1,26 +1,26 @@
# Preload type contants
module GObject
TYPE_INVALID = type_from_name("invalid")
TYPE_NONE = type_from_name("void")
TYPE_INTERFACE = type_from_name("GInterface")
TYPE_CHAR = type_from_name("gchar")
TYPE_UCHAR = type_from_name("guchar")
TYPE_BOOLEAN = type_from_name("gboolean")
TYPE_INT = type_from_name("gint")
TYPE_UINT = type_from_name("guint")
TYPE_LONG = type_from_name("glong")
TYPE_ULONG = type_from_name("gulong")
TYPE_INT64 = type_from_name("gint64")
TYPE_UINT64 = type_from_name("guint64")
TYPE_ENUM = type_from_name("GEnum")
TYPE_FLAGS = type_from_name("GFlags")
TYPE_FLOAT = type_from_name("gfloat")
TYPE_DOUBLE = type_from_name("gdouble")
TYPE_STRING = type_from_name("gchararray")
TYPE_POINTER = type_from_name("gpointer")
TYPE_BOXED = type_from_name("GBoxed")
TYPE_PARAM = type_from_name("GParam")
TYPE_OBJECT = type_from_name("GObject")
TYPE_GTYPE = type_from_name("GType")
TYPE_VARIANT = type_from_name("GVariant")
TYPE_INVALID = type_from_name('invalid')
TYPE_NONE = type_from_name('void')
TYPE_INTERFACE = type_from_name('GInterface')
TYPE_CHAR = type_from_name('gchar')
TYPE_UCHAR = type_from_name('guchar')
TYPE_BOOLEAN = type_from_name('gboolean')
TYPE_INT = type_from_name('gint')
TYPE_UINT = type_from_name('guint')
TYPE_LONG = type_from_name('glong')
TYPE_ULONG = type_from_name('gulong')
TYPE_INT64 = type_from_name('gint64')
TYPE_UINT64 = type_from_name('guint64')
TYPE_ENUM = type_from_name('GEnum')
TYPE_FLAGS = type_from_name('GFlags')
TYPE_FLOAT = type_from_name('gfloat')
TYPE_DOUBLE = type_from_name('gdouble')
TYPE_STRING = type_from_name('gchararray')
TYPE_POINTER = type_from_name('gpointer')
TYPE_BOXED = type_from_name('GBoxed')
TYPE_PARAM = type_from_name('GParam')
TYPE_OBJECT = type_from_name('GObject')
TYPE_GTYPE = type_from_name('GType')
TYPE_VARIANT = type_from_name('GVariant')
end
6 changes: 3 additions & 3 deletions lib/ffi-gobject/object.rb
Expand Up @@ -3,7 +3,7 @@
module GObject
# Overrides for GObject, GObject's generic base class.
class Object
setup_method "new"
setup_method 'new'

# TODO: Generate accessor methods from GIR at class definition time
def method_missing method, *args
Expand All @@ -20,8 +20,8 @@ def signal_connect event, data = nil, &block
GObject.signal_connect(self, event, data, &block)
end

setup_instance_method "get_property"
setup_instance_method "set_property"
setup_instance_method 'get_property'
setup_instance_method 'set_property'

def get_property_extended property_name
gvalue = get_property property_name
Expand Down
6 changes: 3 additions & 3 deletions lib/ffi-gobject_introspection/i_base_info.rb
Expand Up @@ -3,7 +3,7 @@ module GObjectIntrospection
# Decendant types will be implemented as needed.
class IBaseInfo
def initialize ptr, lib = Lib
raise ArgumentError, "ptr must not be null" if ptr.null?
raise ArgumentError, 'ptr must not be null' if ptr.null?

unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
ObjectSpace.define_finalizer self, self.class.make_finalizer(lib, ptr)
Expand Down Expand Up @@ -39,7 +39,7 @@ def to_ptr
def self.build_array_method method, single = nil
method = method.to_s
single ||= method.to_s[0..-2]
count = method.sub(/^(get_)?/, "\\1n_")
count = method.sub(/^(get_)?/, '\\1n_')
class_eval <<-CODE
def #{method}
(0..(#{count} - 1)).map do |i|
Expand Down Expand Up @@ -67,7 +67,7 @@ def #{method}
#
def self.build_finder_method method, counter = nil, fetcher = nil
method = method.to_s
single = method.sub(/^find_/, "")
single = method.sub(/^find_/, '')
counter ||= "n_#{single}s"
fetcher ||= "#{single}"
class_eval <<-CODE
Expand Down
2 changes: 1 addition & 1 deletion lib/ffi-gobject_introspection/i_constant_info.rb
Expand Up @@ -18,7 +18,7 @@ class IConstantInfo < IBaseInfo
def value
case type_tag
when :utf8
raw_value.force_encoding("utf-8")
raw_value.force_encoding('utf-8')
when :gboolean
raw_value != 0
else
Expand Down
2 changes: 1 addition & 1 deletion lib/ffi-gobject_introspection/i_type_info.rb
Expand Up @@ -36,7 +36,7 @@ def zero_terminated?
end

def name
raise "Should not call this for ITypeInfo"
raise 'Should not call this for ITypeInfo'
end
end
end
2 changes: 1 addition & 1 deletion lib/ffi-gobject_introspection/lib.rb
Expand Up @@ -4,7 +4,7 @@ module GObjectIntrospection
# Module for attaching functions from the girepository library
module Lib
extend FFI::Library
ffi_lib "girepository-1.0"
ffi_lib 'girepository-1.0'

# IRepository
enum :IRepositoryLoadFlags, [:LAZY, (1 << 0)]
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi-base/gobject/lib.rb
Expand Up @@ -2,7 +2,7 @@ module GObject
# Module for attaching functions from the gobject library
module Lib
extend FFI::Library
ffi_lib "gobject-2.0"
ffi_lib 'gobject-2.0'
attach_function :g_type_init, [], :void
end
end
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/argument_builder.rb
Expand Up @@ -141,7 +141,7 @@ def caller_allocated_object?

def ingoing_convertor
if skipped?
NullConvertor.new("0")
NullConvertor.new('0')
elsif closure?
ClosureToPointerConvertor.new(name)
elsif @type_info.needs_ruby_to_c_conversion_for_functions?
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/c_to_ruby_convertor.rb
Expand Up @@ -22,7 +22,7 @@ def conversion_arguments
if @type_info.flattened_tag == :c
"#{@type_info.element_type.inspect}, #{array_size}, #{@argument_name}"
else
@type_info.extra_conversion_arguments.map(&:inspect).push(@argument_name).join(", ")
@type_info.extra_conversion_arguments.map(&:inspect).push(@argument_name).join(', ')
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/gir_ffi/builders/callback_argument_builder.rb
Expand Up @@ -44,7 +44,7 @@ def pre_conversion
when :inout
[out_parameter_preparation, ingoing_pre_conversion]
when :error
[out_parameter_preparation, "begin"]
[out_parameter_preparation, 'begin']
end
end

Expand All @@ -56,7 +56,7 @@ def post_conversion
[
"rescue => #{result_name}",
outgoing_post_conversion,
"end"
'end'
]
else
[]
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/field_builder.rb
Expand Up @@ -86,7 +86,7 @@ def field_type
end

def field_argument_info
@field_argument_info ||= FieldArgumentInfo.new "value", field_type
@field_argument_info ||= FieldArgumentInfo.new 'value', field_type
end

def return_value_builder
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/function_builder.rb
Expand Up @@ -71,7 +71,7 @@ def error_argument vargen

def function_call_arguments
ca = @argument_builder_collection.call_argument_names
ca.unshift "self" if @info.method?
ca.unshift 'self' if @info.method?
ca
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/mapping_method_builder.rb
Expand Up @@ -35,7 +35,7 @@ def method_definition
end

def method_name
"call_with_argument_mapping"
'call_with_argument_mapping'
end

def method_arguments
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/marshalling_method_builder.rb
Expand Up @@ -31,7 +31,7 @@ def method_definition
end

def method_name
"marshaller"
'marshaller'
end

def method_arguments
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/method_template.rb
Expand Up @@ -66,7 +66,7 @@ def result

def result_name_list
@result_name_list ||=
@argument_builder_collection.capture_variable_names.join(", ")
@argument_builder_collection.capture_variable_names.join(', ')
end

def capturing_invocation
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/property_builder.rb
Expand Up @@ -109,7 +109,7 @@ def type_info
end

def argument_info
@argument_info ||= FieldArgumentInfo.new("value", type_info)
@argument_info ||= FieldArgumentInfo.new('value', type_info)
end

def container_class
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/builders/ruby_to_c_convertor.rb
Expand Up @@ -12,6 +12,6 @@ def conversion
end

def conversion_arguments name
@type_info.extra_conversion_arguments.map(&:inspect).push(name).join(", ")
@type_info.extra_conversion_arguments.map(&:inspect).push(name).join(', ')
end
end
2 changes: 1 addition & 1 deletion lib/gir_ffi/error_argument_info.rb
Expand Up @@ -16,7 +16,7 @@ def argument_type
end

def name
"_error"
'_error'
end

def closure
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/ffi_ext/pointer.rb
Expand Up @@ -21,7 +21,7 @@ def to_object
end

def to_utf8
null? ? nil : read_string.force_encoding("utf-8")
null? ? nil : read_string.force_encoding('utf-8')
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/gir_ffi/info_ext/safe_constant_name.rb
Expand Up @@ -5,8 +5,8 @@ module SafeConstantName
def safe_name
name.tr('-', '_').gsub(/^./) do |char|
case char
when "_"
"Private___"
when '_'
'Private___'
else
char.upcase
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/info_ext/safe_function_name.rb
Expand Up @@ -4,7 +4,7 @@ module InfoExt
module SafeFunctionName
def safe_name
name = self.name
return "_" if name.empty?
return '_' if name.empty?
name
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gir_ffi/receiver_argument_info.rb
Expand Up @@ -12,6 +12,6 @@ def direction
end

def name
"_instance"
'_instance'
end
end
2 changes: 1 addition & 1 deletion lib/gir_ffi/user_data_argument_info.rb
Expand Up @@ -16,6 +16,6 @@ def skip?
end

def name
"_user_data"
'_user_data'
end
end
2 changes: 1 addition & 1 deletion lib/gir_ffi/version.rb
@@ -1,4 +1,4 @@
# Current GirFFI version
module GirFFI
VERSION = "0.7.7"
VERSION = '0.7.7'
end
6 changes: 3 additions & 3 deletions test/base_test_helper.rb
Expand Up @@ -3,7 +3,7 @@
begin
require 'simplecov'
SimpleCov.start do
add_filter "/test/"
add_filter '/test/'
end
rescue LoadError
end
Expand All @@ -26,9 +26,9 @@ module GObjectIntrospection
class IRepository
def shared_library_with_regress namespace
case namespace
when "Regress"
when 'Regress'
return File.join(File.dirname(__FILE__), 'lib', 'libregress.so')
when "GIMarshallingTests"
when 'GIMarshallingTests'
return File.join(File.dirname(__FILE__), 'lib', 'libgimarshallingtests.so')
else
return shared_library_without_regress namespace
Expand Down

0 comments on commit e79b14b

Please sign in to comment.