Skip to content

Commit

Permalink
enables some rubocop rules and run rubocop -a
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Jun 10, 2017
1 parent e34af13 commit e7fcf7e
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 13 deletions.
42 changes: 41 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
AllCops:
TargetRubyVersion: 2.0
DisabledByDefault: true
DisplayCopNames: true
Exclude:
- tasks/**/*.*

Style:
Enabled: false

Layout:
Enabled: false

Metrics:
Enabled: false

Bundler:
Enabled: false

Performance/RedundantBlockCall:
Enabled: false

Lint/UselessAssignment:
Enabled: false

Lint/UnusedMethodArgument:
Enabled: false

Lint/UnusedBlockArgument:
Enabled: false

Lint/EndAlignment:
Enabled: false

Lint/EmptyWhen:
Enabled: false

Lint/UnneededSplatExpansion:
Enabled: false

# TODO: enable it in a future because `ruby -w` warns it
Lint/AmbiguousRegexpLiteral:
Enabled: false

# TODO: enable it in a future because `ruby -w` warns it
Lint/AmbiguousOperator:
Enabled: false
2 changes: 1 addition & 1 deletion lib/rouge/lexers/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def content_lexer
rule /([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)/ do |m|
key = m[1]
value = m[5]
if key.strip.downcase == 'content-type'
if key.strip.casecmp('content-type').zero?
@content_type = value.split(';')[0].downcase
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rouge/lexers/igorpro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def self.object_name
rule %r(//), Comment, :comments

rule /\b#{object}/ do |m|
if m[0].downcase.match /function/
if m[0].downcase =~ /function/
token Keyword::Declaration
push :parse_function
elsif self.class.igorDeclarations.include? m[0].downcase
Expand All @@ -281,7 +281,7 @@ def self.object_name
elsif self.class.hdf5Operation.include? m[0].downcase
token Keyword::Reserved
push :operationFlags
elsif m[0].downcase.match /(v|s|w)_[a-z]+[a-z0-9]*/
elsif m[0].downcase =~ /(v|s|w)_[a-z]+[a-z0-9]*/
token Name::Builtin
else
token Name
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/matlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Matlab < RegexLexer
mimetypes 'text/x-matlab', 'application/x-matlab'

def self.analyze_text(text)
return 0.4 if text.match(/^\s*% /) # % comments are a dead giveaway
return 0.4 if text =~ /^\s*% / # % comments are a dead giveaway
end

def self.keywords
Expand Down
12 changes: 6 additions & 6 deletions lib/rouge/lexers/mosel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def self.analyze_text(text)
getbstat getdualray getiis getiissense getiistype getinfcause getinfeas getlb getloadedlinctrs getloadedmpvars getname getprimalray getprobstat getrange getsensrng getsize getsol getub getvars
implies indicator isiisvalid isintegral loadbasis
loadmipsol loadprob
maximize, minimize
maximize minimize
postsolve
readbasis readdirs readsol refinemipsol rejectintsol repairinfeas resetbasis resetiis resetsol
savebasis savemipsol savesol savestate selectsol setbstat setcallback setcbcutoff setgndata setlb setmipdir setmodcut setsol setub setucbdata stopoptimize
Expand All @@ -100,15 +100,15 @@ def self.analyze_text(text)
getasnumber getchar getcwd getdate getday getdaynum getdays getdirsep
getendparse setendparse
getenv getfsize getfstat getftime gethour getminute getmonth getmsec getpathsep
getqtype, setqtype
getqtype setqtype
getsecond
getsepchar, setsepchar
getsepchar setsepchar
getsize
getstart, setstart
getsucc, setsucc
getstart setstart
getsucc setsucc
getsysinfo getsysstat gettime
gettmpdir
gettrim, settrim
gettrim settrim
getweekday getyear
inserttext isvalid
makedir makepath newtar
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/lexers/wollok.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def any(expressions)
state :objects do
rule variable_naming do |m|
variable = m[0]
if entities.include?(variable) || ('A'..'Z').include?(variable[0])
if entities.include?(variable) || ('A'..'Z').cover?(variable[0])
token Name::Class
else
token Keyword::Variable
Expand Down
2 changes: 1 addition & 1 deletion lib/rouge/regex_lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def rule(re, tok=nil, next_state=nil, &callback)
proc do |stream|
puts " yielding #{tok.qualname}, #{stream[0].inspect}" if @debug
@output_stream.call(tok, stream[0])
puts " popping stack: #{1}" if @debug
puts " popping stack: 1" if @debug
@stack.pop or raise 'empty stack!'
end
when :push
Expand Down

0 comments on commit e7fcf7e

Please sign in to comment.