Skip to content

Commit

Permalink
Rubocop autocorrected: Style/StringLiterals
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Jun 5, 2015
1 parent 4d020cd commit 06d6501
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 66 deletions.
6 changes: 0 additions & 6 deletions .rubocop.yml
Expand Up @@ -156,12 +156,6 @@ Style/OpMethod:
Style/SingleLineBlockParams:
Enabled: false

# Offense count: 74
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand Down
4 changes: 2 additions & 2 deletions src/ruby/yast.rb
Expand Up @@ -19,10 +19,10 @@
#

# Load the native part (.so)
require 'yastx'
require "yastx"

# load global Yast module
require 'yast/yast'
require "yast/yast"

# load inside moduls
require "yast/arg_ref"
Expand Down
30 changes: 15 additions & 15 deletions src/ruby/yast/ops.rb
Expand Up @@ -12,21 +12,21 @@ module Yast
module Ops
# map of YCPTypes to ruby types
TYPES_MAP = {
'any' => ::Object,
'nil' => ::NilClass,
'void' => ::NilClass,
'boolean' => [::TrueClass, ::FalseClass],
'string' => ::String,
'symbol' => ::Symbol,
'integer' => [::Fixnum, ::Bignum],
'float' => ::Float,
'list' => ::Array,
'map' => ::Hash,
'term' => Yast::Term,
'path' => Yast::Path,
'locale' => ::String,
'function' => [Yast::FunRef, Yast::YReference],
'byteblock' => Yast::Byteblock
"any" => ::Object,
"nil" => ::NilClass,
"void" => ::NilClass,
"boolean" => [::TrueClass, ::FalseClass],
"string" => ::String,
"symbol" => ::Symbol,
"integer" => [::Fixnum, ::Bignum],
"float" => ::Float,
"list" => ::Array,
"map" => ::Hash,
"term" => Yast::Term,
"path" => Yast::Path,
"locale" => ::String,
"function" => [Yast::FunRef, Yast::YReference],
"byteblock" => Yast::Byteblock
}

# Types for which we generate shortcut methods,
Expand Down
8 changes: 4 additions & 4 deletions src/ruby/yast/path.rb
Expand Up @@ -29,7 +29,7 @@ def +(another)
end

def to_s
'.' + components.join('.')
"." + components.join(".")
end

# gets number of elements
Expand Down Expand Up @@ -68,18 +68,18 @@ def load_components(value)
value.each_char do |c|
case state
when :initial
raise "Invalid path '#{value}'" if c != '.'
raise "Invalid path '#{value}'" if c != "."
state = :dot
when :dot
raise "Invalid path '#{value}'" if c == '.'
raise "Invalid path '#{value}'" if c == "."
if c == '"'
state = :complex
else
state = :simple
end
buffer << c
when :simple
if c == '.'
if c == "."
state = :dot
return if invalid_buffer?(buffer)

Expand Down
6 changes: 3 additions & 3 deletions src/ruby/yast/rspec.rb
@@ -1,6 +1,6 @@
require 'yast/rspec/scr'
require 'yast/rspec/shortcuts'
require 'yast/rspec/matchers'
require "yast/rspec/scr"
require "yast/rspec/shortcuts"
require "yast/rspec/matchers"

RSpec.configure do |c|
c.include Yast::RSpec::Shortcuts
Expand Down
6 changes: 3 additions & 3 deletions src/ruby/yast/term.rb
@@ -1,8 +1,8 @@
require "forwardable"

require 'yast/yast'
require 'yast/builtins'
require 'yast/ops'
require "yast/yast"
require "yast/builtins"
require "yast/ops"

module Yast
# Represents YCP type term enhanced by some ruby convenient methods
Expand Down
4 changes: 2 additions & 2 deletions tests/ruby/builtins_spec.rb
Expand Up @@ -718,8 +718,8 @@
# bnc#888585: Incorrect input class raises TypeError
# Only Hash/nil is allowed
expect { Yast::Builtins.mapmap(false) { |k, v| { v => k } } }.to raise_error(TypeError)
expect { Yast::Builtins.mapmap(['Array']) { |k, v| { v => k } } }.to raise_error(TypeError)
expect { Yast::Builtins.mapmap('String') { |k, v| { v => k } } }.to raise_error(TypeError)
expect { Yast::Builtins.mapmap(["Array"]) { |k, v| { v => k } } }.to raise_error(TypeError)
expect { Yast::Builtins.mapmap("String") { |k, v| { v => k } } }.to raise_error(TypeError)
expect { Yast::Builtins.mapmap(32) { |k, v| { v => k } } }.to raise_error(TypeError)

expect(Yast::Builtins.mapmap(nil) { |k, v| { v => k } }).to eq(nil)
Expand Down
20 changes: 10 additions & 10 deletions tests/ruby/convert_spec.rb
Expand Up @@ -14,16 +14,16 @@
describe "OpsTest" do
# data description [object, from, to, result]
CONVERT_TESTDATA = [
[nil, 'any', 'integer', nil],
[nil, 'any', 'term', nil],
[nil, 'any', 'path', nil],
[5, 'any', 'string', nil],
[5, 'integer', 'string', nil],
[5, 'integer', 'string', nil],
[5, 'any', 'integer', 5],
[5.5, 'any', 'integer', 5],
[5.9, 'any', 'integer', 5],
[5, 'any', 'float', 5.0],
[nil, "any", "integer", nil],
[nil, "any", "term", nil],
[nil, "any", "path", nil],
[5, "any", "string", nil],
[5, "integer", "string", nil],
[5, "integer", "string", nil],
[5, "any", "integer", 5],
[5.5, "any", "integer", 5],
[5.9, "any", "integer", 5],
[5, "any", "float", 5.0],
]

it "tests convert" do
Expand Down
2 changes: 1 addition & 1 deletion tests/ruby/exportable_spec.rb
Expand Up @@ -7,7 +7,7 @@

require_relative "test_helper"

require 'yast/exportable'
require "yast/exportable"

class MyTestClass
extend Yast::Exportable
Expand Down
6 changes: 3 additions & 3 deletions tests/ruby/ops_spec.rb
Expand Up @@ -93,9 +93,9 @@
end

it "tests comparison path" do
expect(Yast::Ops.less_than(Yast::Path.new('.'), Yast::Path.new('.etc'))).to eq(true)
expect(Yast::Ops.less_than(Yast::Path.new('.etca'), Yast::Path.new('.etcb'))).to eq(true)
expect(Yast::Ops.less_than(Yast::Path.new('.etc.a'), Yast::Path.new('.etca'))).to eq(true)
expect(Yast::Ops.less_than(Yast::Path.new("."), Yast::Path.new(".etc"))).to eq(true)
expect(Yast::Ops.less_than(Yast::Path.new(".etca"), Yast::Path.new(".etcb"))).to eq(true)
expect(Yast::Ops.less_than(Yast::Path.new(".etc.a"), Yast::Path.new(".etca"))).to eq(true)
end

it "tests comparison nil" do
Expand Down
30 changes: 15 additions & 15 deletions tests/ruby/path_spec.rb
Expand Up @@ -11,7 +11,7 @@
expect(Yast::Path.new(".etc").to_s).to eq(".etc")
end
it "works for complex paths" do
expect(Yast::Path.new('.et?c').to_s).to eq('."et?c"')
expect(Yast::Path.new(".et?c").to_s).to eq('."et?c"')
end
end

Expand All @@ -20,45 +20,45 @@
expect(Yast::Path.from_string("etc").to_s).to eq(".\"etc\"")
end
it "works for complex paths" do
expect(Yast::Path.from_string('et?c').to_s).to eq('."et?c"')
expect(Yast::Path.from_string("et?c").to_s).to eq('."et?c"')
end
end

describe "#+" do
it "works" do
root = Yast::Path.new '.'
etc = Yast::Path.new '.etc'
sysconfig = Yast::Path.new '.sysconfig'
root = Yast::Path.new "."
etc = Yast::Path.new ".etc"
sysconfig = Yast::Path.new ".sysconfig"
expect((etc + sysconfig).to_s).to eq(".etc.sysconfig")
expect((etc + 'sysconfig').to_s).to eq('.etc."sysconfig"')
expect((root + root).to_s).to eq('.')
expect((root + etc).to_s).to eq('.etc')
expect((etc + root).to_s).to eq('.etc')
expect((etc + "sysconfig").to_s).to eq('.etc."sysconfig"')
expect((root + root).to_s).to eq(".")
expect((root + etc).to_s).to eq(".etc")
expect((etc + root).to_s).to eq(".etc")
end
end

describe "#<=>" do
it "works for equality with Path" do
expect(Yast::Path.new(".\"\x1A\"")).to eq(Yast::Path.new(".\"\x1a\""))
expect(Yast::Path.new(".\"A\"")).to eq(Yast::Path.new(".\"\x41\""))
expect(Yast::Path.new('.')).to_not eq(Yast::Path.new(".\"\""))
expect(Yast::Path.new(".")).to_not eq(Yast::Path.new(".\"\""))
end

it "works for ordering Paths" do
expect(Yast::Path.new('.ba')).to be >= Yast::Path.new('."a?"')
expect(Yast::Path.new('."b?"')).to be >= Yast::Path.new('.ab')
expect(Yast::Path.new(".ba")).to be >= Yast::Path.new('."a?"')
expect(Yast::Path.new('."b?"')).to be >= Yast::Path.new(".ab")
end

# bsc#933470
it "survives comparison with a non-Path" do
expect(Yast::Path.new('.foo') <=> 42).to eq nil
expect(Yast::Path.new(".foo") <=> 42).to eq nil
end
end

describe "#clone" do
it "works" do
etc = Yast::Path.new '.etc.sysconfig.DUMP'
expect(etc.clone.to_s).to eq('.etc.sysconfig.DUMP')
etc = Yast::Path.new ".etc.sysconfig.DUMP"
expect(etc.clone.to_s).to eq(".etc.sysconfig.DUMP")
end
end
end
2 changes: 1 addition & 1 deletion tests/ruby/test_helper.rb
@@ -1,4 +1,4 @@
ROOT_DIR = File.expand_path('../../..', __FILE__)
ROOT_DIR = File.expand_path("../../..", __FILE__)
binary_path = "#{ROOT_DIR}/build/src/binary"
require "fileutils"
if !File.exists? "#{binary_path}/yast"
Expand Down
2 changes: 1 addition & 1 deletion tests/ycp/URI.rb
@@ -1,4 +1,4 @@
require 'uri'
require "uri"
module URI
# URI::parse works even without glue

Expand Down

0 comments on commit 06d6501

Please sign in to comment.