Skip to content

Commit

Permalink
Silence warnings emitted while running tests (#4134)
Browse files Browse the repository at this point in the history
* Silence warnings being emitted when running tests

Fixes two warnings displayed in recent test feedback:

* lib/linguist/heuristics.rb:414:
  warning: character class has duplicated range:

      /[A-Z\.][\w\d\.]*:{/

* lib/linguist/language.rb:504:
  warning: assigned but unused variable:

      filenames

* Remove unused `filenames` variable
  • Loading branch information
Alhadis authored May 21, 2018
1 parent 5dff91d commit 44f107b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/linguist/heuristics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def call(data)
end

disambiguate ".q" do |data|
if /[A-Z\.][\w\d\.]*:{/i.match(data) || /(^|\n)\\(cd?|d|l|p|ts?) /.match(data)
if /[A-Z.][\w.]*:{/i.match(data) || /(^|\n)\\(cd?|d|l|p|ts?) /.match(data)
Language["q"]
elsif /SELECT\s+[\w*,]+\s+FROM/i.match(data) || /(CREATE|ALTER|DROP)\s(DATABASE|SCHEMA|TABLE)/i.match(data)
Language["HiveQL"]
Expand Down
27 changes: 12 additions & 15 deletions lib/linguist/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class Language
@alias_index = {}
@language_id_index = {}

@extension_index = Hash.new { |h,k| h[k] = [] }
@interpreter_index = Hash.new { |h,k| h[k] = [] }
@filename_index = Hash.new { |h,k| h[k] = [] }
@extension_index = Hash.new { |h,k| h[k] = [] }
@interpreter_index = Hash.new { |h,k| h[k] = [] }
@filename_index = Hash.new { |h,k| h[k] = [] }

# Valid Languages types
TYPES = [:data, :markup, :programming, :prose]
Expand Down Expand Up @@ -291,9 +291,9 @@ def initialize(attributes = {})
@language_id = attributes[:language_id]

# Set extensions or default to [].
@extensions = attributes[:extensions] || []
@interpreters = attributes[:interpreters] || []
@filenames = attributes[:filenames] || []
@extensions = attributes[:extensions] || []
@interpreters = attributes[:interpreters] || []
@filenames = attributes[:filenames] || []

# Set popular, and searchable flags
@popular = attributes.key?(:popular) ? attributes[:popular] : false
Expand Down Expand Up @@ -499,12 +499,11 @@ def inspect
end
end

extensions = Samples.cache['extnames']
extensions = Samples.cache['extnames']
interpreters = Samples.cache['interpreters']
filenames = Samples.cache['filenames']
popular = YAML.load_file(File.expand_path("../popular.yml", __FILE__))
popular = YAML.load_file(File.expand_path("../popular.yml", __FILE__))

languages_yml = File.expand_path("../languages.yml", __FILE__)
languages_yml = File.expand_path("../languages.yml", __FILE__)
languages_json = File.expand_path("../languages.json", __FILE__)

if File.exist?(languages_json) && defined?(Yajl)
Expand All @@ -514,9 +513,9 @@ def inspect
end

languages.each do |name, options|
options['extensions'] ||= []
options['extensions'] ||= []
options['interpreters'] ||= []
options['filenames'] ||= []
options['filenames'] ||= []

if extnames = extensions[name]
extnames.each do |extname|
Expand All @@ -527,9 +526,7 @@ def inspect
end
end

if interpreters == nil
interpreters = {}
end
interpreters ||= {}

if interpreter_names = interpreters[name]
interpreter_names.each do |interpreter|
Expand Down

0 comments on commit 44f107b

Please sign in to comment.