Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto corrected by following Format Ruby Code #749

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ task :default => :cucumber
# task :all => [ :bundleup, :up, :cucumber, :'gem:make', :distclean ]
# task :build => [ :bundleup, :up, :cucumber, :rdoc,
# :'gem:build', :'gem:install', :distclean ]

6 changes: 3 additions & 3 deletions features/step_definitions/mixin_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
end

if @плодъ != плодъ
raise "Плодна Страза со значенꙇемъ '#{@плодъ}' должна имѣти значенꙇе " \
"'#{плодъ}'"
raise "Плодна Страза со значенꙇемъ '#{@плодъ}' должна имѣти значенꙇе '#{плодъ}'"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming/AsciiIdentifiers: Use only ascii symbols in identifiers.
Metrics/LineLength: Line is too long. [84/80]

end
end

Expand Down Expand Up @@ -257,7 +256,8 @@
end

То(/^исключение невѣрнѣ опции вызвано будетъ$/) do
expect { @проц.call }.to raise_error(Rdoba::Mixin::InvalidOption)
expect { @проц.call }
.to raise_error(Rdoba::Mixin::InvalidOption)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

end

# #!/usr/bin/ruby -KU
Expand Down
4 changes: 2 additions & 2 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

RdobaSimSimpleHead = <<~HEAD
#!/usr/bin/env ruby

require 'rdoba'
HEAD

RdobaSimClsHead = <<~HEAD
#!/usr/bin/env ruby

require 'rdoba'
class Cls
HEAD
Expand Down
3 changes: 2 additions & 1 deletion features/support/mixin_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

module MixinSupport
def random_string(count)
Random.new.bytes((count + 1) / 2).split('').map do |b| b.ord.to_s(16)end.join[0...count]
Random.new.bytes((count + 1) / 2).split('').map do |b| b.ord.to_s(16) end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Style/BlockDelimiters: Prefer {...} over do...end for single-line blocks.

.join[0...count]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the previous line, together with the method call receiver.

end

def tmpfile
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoba/a.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Hash
def geta_value(cid, options = {})
res =
(!cid || cid.empty?) && self || self[cid] ||
(options[:сокр] && (self[options[:сокр][cid]] || self[options[:сокр].reverse[cid]]))
(options[:сокр] && (self[options[:сокр][cid]] || self[options[:сокр].reverse[cid]]))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [90/80]


if !res and options[:try_regexp]
keys.each do |key|
Expand Down
24 changes: 12 additions & 12 deletions lib/rdoba/blank.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class Object
def blank?
case self
when NilClass, FalseClass
true
when TrueClass
false
when Hash, Array
!self.any?
else
self.to_s == ""
end
end
def blank?
case self
when NilClass, FalseClass
true
when TrueClass
false
when Hash, Array
!self.any?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/InverseMethods: Use none? instead of inverting any?.
Style/RedundantSelf: Redundant self detected.

else
self.to_s == ""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RedundantSelf: Redundant self detected.

end
end
end
44 changes: 22 additions & 22 deletions lib/rdoba/combinations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
# frozen_string_literal: true

class Array
public
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAccessModifier: Useless public access modifier.


def each_comby(*args)
return self if empty? or !block_given?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/AndOr: Use || instead of or.


if args.include?(:backward)
yield [dup]
((1 << (size - 1)) - 2).downto(0) do |i|
c = __comby(i, size - 1)
yield c
end
else
0.upto((1 << (size - 1)) - 2) do |i|
c = __comby(i, size - 1)
yield c
end
yield [dup]
end

self
end

private

def __comby(i, size)
Expand Down Expand Up @@ -36,26 +58,4 @@ def up0(v)
up0(v) if v[:c0] > 1
v[:res]
end

public

def each_comby(*args)
return self if empty? or !block_given?

if args.include?(:backward)
yield [dup]
((1 << (size - 1)) - 2).downto(0) do |i|
c = __comby(i, size - 1)
yield c
end
else
0.upto((1 << (size - 1)) - 2) do |i|
c = __comby(i, size - 1)
yield c
end
yield [dup]
end

self
end
end
4 changes: 2 additions & 2 deletions lib/rdoba/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def parse_opts(opts)
end

def apply_opts(opts)
parse_opts(opts).each do |x, y| instance_variable_set("@#{x}".to_sym, y)end
parse_opts(opts).each do |x, y| instance_variable_set("@#{x}".to_sym, y) end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/BlockDelimiters: Prefer {...} over do...end for single-line blocks.

end
end

Expand Down Expand Up @@ -103,7 +103,7 @@ def -(other)
(0...len).each do |idx|
break bc = idx if self[idx] == other[0]
end
((bc + 1)...len).each do |idx| break ec = idx if self[idx] != other[idx - bc]end if bc
((bc + 1)...len).each do |idx| break ec = idx if self[idx] != other[idx - bc] end if bc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/BlockDelimiters: Prefer {...} over do...end for single-line blocks.
Metrics/LineLength: Line is too long. [91/80]

bc ? ec ? self[0, bc] + self[ec, len - ec] : self[0, bc] : clone
end

Expand Down
3 changes: 1 addition & 2 deletions lib/rdoba/debug.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

warn "Warning: the module has kept only for backward compatibility\n" \
"Please use 'rdoba :log' form instead"
warn "Warning: the module has kept only for backward compatibility\nPlease use 'rdoba :log' form instead"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [105/80]


require 'rdoba/log'

Expand Down
64 changes: 32 additions & 32 deletions lib/rdoba/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def sprintf(format, *args)
indent = ' ' * (Regexp.last_match(2) == '*' ? args.shift : Regexp.last_match(2)).to_i
plain =
value &&
value.to_p(
padding:
(Regexp.last_match(3) == '*' ? args.shift : Regexp.last_match(3).empty? ? 1 : Regexp.last_match(3))
.to_i,
be: Regexp.last_match(4).empty? ? nil : true
) || ''
value.to_p(
padding:
(Regexp.last_match(3) == '*' ? args.shift : Regexp.last_match(3).empty? ? 1 : Regexp.last_match(3))
.to_i,
be: Regexp.last_match(4).empty? ? nil : true
) || ''
nformat += (Regexp.last_match(1) ? plain + indent : indent + plain) + str
else
nformat += '%' + keys + 'c' + str
Expand Down Expand Up @@ -63,32 +63,32 @@ def scanf_re(format)
#  TODO add performing the special case in fss[1]
nformat +=
fss.pre_match[pos..-1].to_res +
case fss[4]
when 'x'
'(?:0[xX])?([a-fA-F0-9]+)'
when 'i'
'([+\-]?[0-9]+)'
when 'u'
'([0-9]+)'
when 'e'
'([+\-]?[0-9]+[eE][+\-]?[0-9]+)'
when 'f'
'([+\-]?[0-9]+\.[0-9]*)'
when 'g'
'([+\-]?[0-9]+(?:[eE][+\-]?[0-9]+|\.[0-9]*))'
when 'c'
fss[2] ? "(.{1,#{fss[2]}})" : '(.)'
when 'b'
'([01]+)b?'
when 'o'
'0([0-9]+)'
when 'd'
'([+\-]?(?:0X)?[A-F0-9.+]+)'
when 's'
'(.+)'
when 'r'
'([IVXLCDMivxlcdm]+)'
end
case fss[4]
when 'x'
'(?:0[xX])?([a-fA-F0-9]+)'
when 'i'
'([+\-]?[0-9]+)'
when 'u'
'([0-9]+)'
when 'e'
'([+\-]?[0-9]+[eE][+\-]?[0-9]+)'
when 'f'
'([+\-]?[0-9]+\.[0-9]*)'
when 'g'
'([+\-]?[0-9]+(?:[eE][+\-]?[0-9]+|\.[0-9]*))'
when 'c'
fss[2] ? "(.{1,#{fss[2]}})" : '(.)'
when 'b'
'([01]+)b?'
when 'o'
'0([0-9]+)'
when 'd'
'([+\-]?(?:0X)?[A-F0-9.+]+)'
when 's'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

'(.+)'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

when 'r'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

'([IVXLCDMivxlcdm]+)'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

end

pos = fss.pos
end
Expand Down
8 changes: 5 additions & 3 deletions lib/rdoba/mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ def crop_diacritics(x)
(x < 0x300 || x > 0x36f && x < 0x483 || x > 0x487 && x < 0xa67c || x > 0xa67d) && x || nil
end

(unpack('U*').map do |x| crop_diacritics(x)end.compact) <=>
(value.unpack('U*').map do |x| crop_diacritics(x)end.compact)
(unpack('U*').map do |x| crop_diacritics(x) end
.compact) <=>
(value.unpack('U*').map do |x| crop_diacritics(x) end
.compact)
else
self <=> value
end
Expand Down Expand Up @@ -295,7 +297,7 @@ module Split_byArray
#
def split_by
idxs = []
rejected = reject.with_index do |v, i| yield(v) && (idxs << i)end
rejected = reject.with_index do |v, i| yield(v) && (idxs << i) end
[values_at(*idxs), rejected]
end
end
Expand Down
Loading