Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Attempt to Fix all warnings from Sass. #1146

Closed
wants to merge 1 commit into from

2 participants

@vipulnsward

Hi all, This is an attempt to fix different kinds of warnings form

  • Circular dependency loading
  • Un- initialized variable.
  • Use of File.exists? instead of File.exist?
  • Parenthesis around ambiguous arguments, etc.

Not sure what the policy is about this. Just an attempt to clear out some warnings I see on Sinatra builds. (https://travis-ci.org/sinatra/sinatra/jobs/19503469)

@vipulnsward vipulnsward Fix warnings from-
* Circular dependency loading
* Un- initialized variable.
* Use of File.exists? instead of File.exist?
* Paranthesis around ambiguous arguments, etc.
e46eb58
@nex3
Owner

We're not interested in avoiding warnings caused by uninitialized instance variables. We consider instance variables defaulting to nil to be a feature of Ruby, and use it accordingly.

If you remove the instance-variable changes, I'll merge this.

@vipulnsward

Actually it just returns nil value, doesn't default to setting/initializing it.
ruby/ruby@b996367

Do you wan't to me to remove the initializations to nil, with such a behaviour from Ruby?
Let me know, I'l update the PR.

@nex3
Owner

Yes, please do remove the nil initializations.

@vipulnsward

I see that all changes are already in master.

@vipulnsward vipulnsward closed this
@sds sds referenced this pull request in brigade/scss-lint
Closed

Sass 3.4 #218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 5, 2014
  1. @vipulnsward

    Fix warnings from-

    vipulnsward authored
    * Circular dependency loading
    * Un- initialized variable.
    * Use of File.exists? instead of File.exist?
    * Paranthesis around ambiguous arguments, etc.
This page is out of date. Refresh to see the latest.
View
1  Rakefile
@@ -19,6 +19,7 @@ Rake::TestTask.new do |t|
test_files.exclude(scope('test/plugins/*'))
t.test_files = test_files
t.verbose = true
+ t.warning = true
end
# ----- Code Style Enforcement -----
View
1  lib/sass/css.rb
@@ -35,6 +35,7 @@ def initialize(template, options = {})
# Backwards compatibility
@options[:old] = true if @options[:alternate] == false
@template = template
+ @checked_encoding = nil
end
# Converts the CSS template into Sass or SCSS code.
View
1  lib/sass/engine.rb
@@ -261,6 +261,7 @@ def self.for_file(filename, options)
def initialize(template, options = {})
@options = self.class.normalize_options(options)
@template = template
+ @checked_encoding = @filename = @content = @line = nil
end
# Render the template to CSS.
View
12 lib/sass/environment.rb
@@ -95,9 +95,14 @@ def set_local_#{name}(name, value)
def initialize(parent = nil, options = nil)
@parent = parent
@options = options || (parent && parent.options) || {}
- @stack = Sass::Stack.new if @parent.nil?
+ if @parent.nil?
+ @stack = Sass::Stack.new
+ else
+ @stack = nil
+ end
@global_warning_given = Set.new
@deprecated_false_warning_given = Set.new
+ @selector = @vars = @mixins = @functions = @caller = @content = nil
end
# The environment of the caller of this environment's mixin or function.
@@ -168,6 +173,11 @@ class Environment < BaseEnvironment
# function
# Sass::Callable
inherited_hash_writer :function
+
+ def initialize(*args)
+ super(*args)
+ @vars = @mixin = @function = nil
+ end
end
# A read-only wrapper for a lexical environment for SassScript.
View
4 lib/sass/exec.rb
@@ -682,7 +682,7 @@ def process_directory
unless File.directory?(@options[:input])
raise "Error: '#{@options[:input]}' is not a directory"
end
- if @options[:output] && File.exists?(@options[:output]) &&
+ if @options[:output] && File.exist?(@options[:output]) &&
!File.directory?(@options[:output])
raise "Error: '#{@options[:output]}' is not a directory"
end
@@ -711,7 +711,7 @@ def process_directory
FileUtils.mkdir_p(File.dirname(output))
end
puts_action :convert, :green, f
- if File.exists?(output)
+ if File.exist?(output)
puts_action :overwrite, :yellow, output
else
puts_action :create, :green, output
View
9 lib/sass/plugin/compiler.rb
@@ -34,6 +34,7 @@ class Compiler
# @param opts [{Symbol => Object}]
# See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
def initialize(opts = {})
+ @_sass_callbacks = {}
options.merge!(opts)
end
@@ -281,7 +282,7 @@ def watch(individual_files = [])
if recompile_required
# In case a file we're watching is removed and then recreated we
# prune out the non-existant files here.
- watched_files_remaining = individual_files.select {|(source, _, _)| File.exists?(source)}
+ watched_files_remaining = individual_files.select {|(source, _, _)| File.exist?(source)}
update_stylesheets(watched_files_remaining)
end
end
@@ -354,7 +355,7 @@ def remove_redundant_directories(directories)
def update_stylesheet(filename, css, sourcemap)
dir = File.dirname(css)
- unless File.exists?(dir)
+ unless File.exist?(dir)
run_creating_directory dir
FileUtils.mkdir_p dir
end
@@ -394,12 +395,12 @@ def write_file(fileName, content)
end
def try_delete_css(css)
- if File.exists?(css)
+ if File.exist?(css)
run_deleting_css css
File.delete css
end
map = Sass::Util.sourcemap_name(css)
- if File.exists?(map)
+ if File.exist?(map)
run_deleting_sourcemap map
File.delete map
end
View
1  lib/sass/script/lexer.rb
@@ -151,6 +151,7 @@ def initialize(str, line, offset, options)
@options = options
@interpolation_stack = []
@prev = nil
+ @tok = nil
end
# Moves the lexer forward one token.
View
1  lib/sass/script/parser.rb
@@ -29,6 +29,7 @@ def offset
def initialize(str, line, offset, options = {})
@options = options
@lexer = lexer_class.new(str, line, offset, options)
+ @in_parens = @stop_at = nil
end
# Parses a SassScript expression within an interpolated segment (`#{}`).
View
2  lib/sass/script/value/deprecated_false.rb
@@ -14,6 +14,8 @@ def initialize(environment)
if (frame = environment.stack.frames.last)
@filename = frame.filename
@line = frame.line
+ else
+ @filename = @line = nil
end
end
View
1  lib/sass/script/value/list.rb
@@ -21,6 +21,7 @@ class List < Base
def initialize(value, separator)
super(value)
@separator = separator
+ @map = nil
end
# @see Value#options=
View
1  lib/sass/scss/parser.rb
@@ -30,6 +30,7 @@ def initialize(str, filename, importer, line = 1, offset = 1)
@line = line
@offset = offset
@strs = []
+ @throw_error = @use_property_exception = @expected = nil
end
# Parses an SCSS document.
View
1  lib/sass/tree/node.rb
@@ -90,6 +90,7 @@ def invalid_parent_method_name
def initialize
@children = []
+ @filename = @options = nil
end
# Sets the options hash for the node and all its children.
View
1  lib/sass/tree/rule_node.rb
@@ -68,6 +68,7 @@ def initialize(rule, selector_source_range = nil)
@rule = Sass::Util.strip_string_array(merged)
@selector_source_range = selector_source_range
@tabs = 0
+ @parsed_rules = nil
try_to_parse_non_interpolated_rules
super()
end
View
1  lib/sass/tree/visitors/check_nesting.rb
@@ -4,6 +4,7 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
def initialize
@parents = []
+ @parent = @current_mixin_def = nil
end
def visit(node)
View
1  lib/sass/tree/visitors/convert.rb
@@ -16,6 +16,7 @@ def initialize(options, format)
@options = options
@format = format
@tabs = 0
+ @is_else = nil
# 2 spaces by default
@tab_chars = @options[:indent] || " "
end
View
1  lib/sass/tree/visitors/perform.rb
@@ -143,6 +143,7 @@ def arg_hash(map)
protected
def initialize(env)
+ @at_root_without_rule = nil
@environment = env
end
View
7 lib/sass/tree/visitors/to_css.rb
@@ -13,7 +13,12 @@ def initialize(build_source_mapping = false)
@line = 1
@offset = 1
@result = ""
- @source_mapping = Sass::Source::Map.new if build_source_mapping
+ @lstrip = @in_directive = nil
+ if build_source_mapping
+ @source_mapping = Sass::Source::Map.new
+ else
+ @source_mapping = nil
+ end
end
# Runs the visitor on `node`.
View
1  lib/sass/util/normalized_map.rb
@@ -1,5 +1,4 @@
require 'delegate'
-require 'sass/util'
module Sass
module Util
View
10 lib/sass/version.rb
@@ -85,20 +85,20 @@ def version
private
def revision_number
- if File.exists?(Sass::Util.scope('REVISION'))
+ if File.exist?(Sass::Util.scope('REVISION'))
rev = File.read(Sass::Util.scope('REVISION')).strip
return rev unless rev =~ /^([a-f0-9]+|\(.*\))$/ || rev == '(unknown)'
end
- return unless File.exists?(Sass::Util.scope('.git/HEAD'))
+ return unless File.exist?(Sass::Util.scope('.git/HEAD'))
rev = File.read(Sass::Util.scope('.git/HEAD')).strip
return rev unless rev =~ /^ref: (.*)$/
ref_name = $1
ref_file = Sass::Util.scope(".git/#{ref_name}")
info_file = Sass::Util.scope(".git/info/refs")
- return File.read(ref_file).strip if File.exists?(ref_file)
- return unless File.exists?(info_file)
+ return File.read(ref_file).strip if File.exist?(ref_file)
+ return unless File.exist?(info_file)
File.open(info_file) do |f|
f.each do |l|
sha, ref = l.strip.split("\t", 2)
@@ -110,7 +110,7 @@ def revision_number
end
def version_date
- return unless File.exists?(Sass::Util.scope('VERSION_DATE'))
+ return unless File.exist?(Sass::Util.scope('VERSION_DATE'))
DateTime.parse(File.read(Sass::Util.scope('VERSION_DATE')).strip)
end
end
View
20 test/sass/cache_test.rb
@@ -18,42 +18,42 @@ def teardown
def test_file_cache_writes_a_file
file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
file_store.store("asdf/foo.scssc", "fakesha1", root_node)
- assert File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
end
def test_file_cache_reads_a_file
file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
file_store.store("asdf/foo.scssc", "fakesha1", root_node)
- assert File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
assert_kind_of Sass::Tree::RootNode, file_store.retrieve("asdf/foo.scssc", "fakesha1")
end
def test_file_cache_miss_returns_nil
file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
assert_nil file_store.retrieve("asdf/foo.scssc", "fakesha1")
end
def test_sha_change_invalidates_cache_and_cleans_up
file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
file_store.store("asdf/foo.scssc", "fakesha1", root_node)
- assert File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
assert_nil file_store.retrieve("asdf/foo.scssc", "differentsha1")
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
end
def test_version_change_invalidates_cache_and_cleans_up
file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
file_store.store("asdf/foo.scssc", "fakesha1", root_node)
- assert File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
real_version = Sass::VERSION
begin
Sass::VERSION.replace("a different version")
assert_nil file_store.retrieve("asdf/foo.scssc", "fakesha1")
- assert !File.exists?("#{@@cache_dir}/asdf/foo.scssc")
+ assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
ensure
Sass::VERSION.replace(real_version)
end
View
12 test/sass/engine_test.rb
@@ -648,18 +648,18 @@ def test_url_import
def test_sass_import
sassc_file = sassc_path("importee")
- assert !File.exists?(sassc_file)
+ assert !File.exist?(sassc_file)
renders_correctly "import", { :style => :compact, :load_paths => [File.dirname(__FILE__) + "/templates"] }
- assert File.exists?(sassc_file)
+ assert File.exist?(sassc_file)
end
def test_sass_pathname_import
sassc_file = sassc_path("importee")
- assert !File.exists?(sassc_file)
+ assert !File.exist?(sassc_file)
renders_correctly("import",
:style => :compact,
:load_paths => [Pathname.new(File.dirname(__FILE__) + "/templates")])
- assert File.exists?(sassc_file)
+ assert File.exist?(sassc_file)
end
def test_import_from_global_load_paths
@@ -691,12 +691,12 @@ def test_nonexistent_extensionless_import
end
def test_no_cache
- assert !File.exists?(sassc_path("importee"))
+ assert !File.exist?(sassc_path("importee"))
renders_correctly("import", {
:style => :compact, :cache => false,
:load_paths => [File.dirname(__FILE__) + "/templates"],
})
- assert !File.exists?(sassc_path("importee"))
+ assert !File.exist?(sassc_path("importee"))
end
def test_import_in_rule
View
4 test/sass/plugin_test.rb
@@ -209,7 +209,7 @@ def test_two_template_directories_with_line_annotations
end
def test_doesnt_render_partials
- assert !File.exists?(tempfile_loc('_partial'))
+ assert !File.exist?(tempfile_loc('_partial'))
end
def test_template_location_array
@@ -507,7 +507,7 @@ def reset_mtimes
def template_loc(name = nil, prefix = nil)
if name
scss = absolutize "#{prefix}templates/#{name}.scss"
- File.exists?(scss) ? scss : absolutize("#{prefix}templates/#{name}.sass")
+ File.exist?(scss) ? scss : absolutize("#{prefix}templates/#{name}.sass")
else
absolutize "#{prefix}templates"
end
Something went wrong with that request. Please try again.