Fix Warnings #695

Closed
wants to merge 16 commits into
from
View
@@ -17,6 +17,7 @@ Rake::TestTask.new do |t|
test_files.exclude(scope('test/plugins/*'))
t.test_files = test_files
t.verbose = true
+ t.warning = true
end
# ----- Packaging -----
View
@@ -55,7 +55,7 @@ def on_#{name}(&block)
end
def run_#{name}(*args)
- return unless @_sass_callbacks
+ return unless defined?(@_sass_callbacks) && @_sass_callbacks
return unless @_sass_callbacks[#{name.inspect}]
@_sass_callbacks[#{name.inspect}].each {|c| c[*args]}
end
View
@@ -31,6 +31,7 @@ def initialize(template, options = {})
template = template.read
end
+ @checked_encoding = nil
@options = options.dup
# Backwards compatibility
@options[:old] = true if @options[:alternate] == false
View
@@ -252,6 +252,9 @@ def self.for_file(filename, options)
def initialize(template, options={})
@options = self.class.normalize_options(options)
@template = template
+ @filename = nil
+ @checked_encoding = nil
+ @line = nil
end
# Render the template to CSS.
@@ -353,7 +356,7 @@ def _render_with_sourcemap(sourcemap_uri)
rendered << "\n" if rendered[-1] != ?\n
rendered << "\n" unless compressed
rendered << "/*@ sourceMappingURL="
- rendered << URI.encode(sourcemap_uri)
+ rendered << Sass::Util.escape_uri(sourcemap_uri)
rendered << " */"
rendered = encode_and_set_charset(rendered)
return rendered, sourcemap
@@ -673,9 +676,7 @@ def parse_property_or_rule(line)
property
else
res.pop if comment
- scanner_start_pos = scanner.pos
interp_parsed = parse_interp(scanner.rest)
- scanned_size = scanner.pos - scanner_start_pos
selector_range = Sass::Source::Range.new(
ident_range.start_pos,
Sass::Source::Position.new(@line, to_parser_offset(line.offset) + line.text.length),
@@ -911,7 +912,7 @@ def parse_import(line, value, offset)
def parse_import_arg(scanner, offset)
return if scanner.eos?
- if match_length = scanner.match?(/url\(/i)
+ if scanner.match?(/url\(/i)
script_parser = Sass::Script::Parser.new(scanner, @line, to_parser_offset(offset), @options)
str = script_parser.parse_string
View
@@ -27,6 +27,8 @@ class Environment
# @param parent [Environment] See \{#parent}
def initialize(parent = nil, options = nil)
@parent = parent
+ @caller = nil
+ @content = nil
@options = options || (parent && parent.options) || {}
end
@@ -62,7 +64,7 @@ def #{name}(name)
end
def _#{name}(name)
- (@#{name}s && @#{name}s[name]) || @parent && @parent._#{name}(name)
+ (defined?(@#{name}s) && @#{name}s && @#{name}s[name]) || @parent && @parent._#{name}(name)
end
protected :_#{name}
View
@@ -1,5 +1,3 @@
-require 'sass/script/literal'
-
module Sass::Script
# A SassScript object representing a boolean (true or false) value.
class Bool < Literal
View
@@ -1,5 +1,3 @@
-require 'sass/script/literal'
-
module Sass::Script
# A SassScript object representing a CSS color.
#
View
@@ -138,6 +138,7 @@ def initialize(str, line, offset, options)
@options = options
@interpolation_stack = []
@prev = nil
+ @tok = nil
end
# Moves the lexer forward one token.
View
@@ -1,5 +1,3 @@
-require 'sass/script/literal'
-
module Sass::Script
# A SassScript object representing a null value.
class Null < Literal
@@ -1,5 +1,3 @@
-require 'sass/script/literal'
-
module Sass::Script
# A SassScript object representing a number.
# SassScript numbers can have decimal values,
@@ -1,7 +1,10 @@
require 'set'
+require 'sass/script/literal'
require 'sass/script/string'
require 'sass/script/number'
require 'sass/script/color'
+require 'sass/script/bool'
+require 'sass/script/null'
require 'sass/script/functions'
require 'sass/script/unary_operation'
require 'sass/script/interpolation'
@@ -35,7 +38,6 @@ def inspect
# @see Node#to_sass
def to_sass(opts = {})
- pred = Sass::Script::Parser.precedence_of(@operator)
o1 = operand_to_sass @operand1, :left, opts
o2 = operand_to_sass @operand2, :right, opts
sep =
@@ -29,6 +29,8 @@ def offset
def initialize(str, line, offset, options = {})
@options = options
@lexer = lexer_class.new(str, line, offset, options)
+ @stop_at = nil
+ @in_parens = nil
end
# Parses a SassScript expression within an interpolated segment (`#{}`).
@@ -282,12 +284,15 @@ def expr
production :equals, :interpolation, :single_eq
+ WA = true # :nodoc:
+ WB = true # :nodoc:
+
def try_op_before_interp(op, prev = nil)
return unless @lexer.peek && @lexer.peek.type == :begin_interpolation
wb = @lexer.whitespace?(op)
str = Script::String.new(Lexer::OPERATORS_REVERSE[op.type])
str.line = @lexer.line
- interp = Script::Interpolation.new(prev, str, nil, wb, !:wa, :originally_text)
+ interp = Script::Interpolation.new(prev, str, nil, wb, !WA, :originally_text)
interp.line = @lexer.line
interpolation(interp)
end
@@ -301,7 +306,7 @@ def try_ops_after_interp(ops, name, prev = nil)
str = Script::String.new(Lexer::OPERATORS_REVERSE[op.type])
str.line = @lexer.line
start_pos = source_position
- interp = Script::Interpolation.new(prev, str, assert_expr(name), !:wb, wa, :originally_text)
+ interp = Script::Interpolation.new(prev, str, assert_expr(name), !WB, wa, :originally_text)
interp.line = @lexer.line
interp.source_range = range(start_pos)
return interp
@@ -1,5 +1,3 @@
-require 'sass/script/literal'
-
module Sass::Script
# A SassScript object representing a CSS string *or* a CSS identifier.
class String < Literal
View
@@ -28,6 +28,10 @@ def initialize(str, filename, importer, line = 1, offset = 1)
@line = line
@offset = offset
@strs = []
+ @throw_error = nil
+ @throw_err = nil
+ @use_property_exception = nil
+ @expected = nil
end
# Parses an SCSS document.
@@ -459,9 +463,11 @@ def _moz_document_directive(start_pos)
directive_body(res.flatten, start_pos)
end
+ ALLOW_VAR = true # :nodoc:
+
def moz_document_function
return unless val = interp_uri || _interp_string(:url_prefix) ||
- _interp_string(:domain) || function(!:allow_var) || interpolation
+ _interp_string(:domain) || function(!ALLOW_VAR) || interpolation
ss
val
end
@@ -696,7 +702,7 @@ def simple_selector_sequence
# http://www.w3.org/TR/css3-animations/#keyframes-
start_pos = source_position
- return expr(!:allow_var) unless e = element_name || id_selector ||
+ return expr(!ALLOW_VAR) unless e = element_name || id_selector ||
class_selector || placeholder_selector || attrib || pseudo ||
parent_selector || interpolation_selector
res = [e]
@@ -26,9 +26,11 @@ def parse_selector
private
+ ALLOW_VAR = true # :nodoc:
+
def moz_document_function
return unless val = tok(URI) || tok(URL_PREFIX) || tok(DOMAIN) ||
- function(!:allow_var)
+ function(!ALLOW_VAR)
ss
[val]
end
@@ -255,7 +255,7 @@ def merge_final_ops(seq1, seq2, res = [])
# is a supersequence of the other, use that, otherwise give up.
lcs = Sass::Util.lcs(ops1, ops2)
return unless lcs == ops1 || lcs == ops2
- res.unshift *(ops1.size > ops2.size ? ops1 : ops2).reverse
+ res.unshift(*(ops1.size > ops2.size ? ops1 : ops2).reverse)
return res
end
@@ -135,9 +135,9 @@ def do_extend(extends, parent_directives, seen = Set.new)
# by the time extension and unification happen,
# this exception will only ever be raised as a result of programmer error
def unify(sels, other_subject)
- return unless sseq = members.inject(sels) do |sseq, sel|
- return unless sseq
- sel.unify(sseq)
+ return unless sseq = members.inject(sels) do |member, sel|
+ return unless member
+ sel.unify(member)
end
SimpleSequence.new(sseq, other_subject || subject?)
end
View
@@ -32,7 +32,7 @@ class Node
# The child nodes of this node.
#
# @return [Array<Tree::Node>]
- attr_accessor :children
+ attr_reader :children
# Whether or not this node has child nodes.
# This may be true even when \{#children} is empty,
@@ -64,6 +64,8 @@ class Node
def initialize
@children = []
+ @filename = nil
+ @options = nil
end
# Sets the options hash for the node and all its children.
@@ -1,5 +1,4 @@
require 'pathname'
-require 'uri'
module Sass::Tree
# A static node reprenting a CSS rule.
@@ -69,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
@@ -115,7 +115,7 @@ def continued?
#
# @return [{#to_s => #to_s}]
def debug_info
- {:filename => filename && ("file://" + URI.escape(File.expand_path(filename))),
+ {:filename => filename && ("file://" + Sass::Util.escape_uri(File.expand_path(filename))),
:line => self.line}
end
@@ -4,6 +4,8 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
def initialize
@parents = []
+ @parent = nil
+ @current_mixin_def = nil
end
def visit(node)
@@ -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
@@ -14,6 +14,7 @@ def self.visit(root); super; end
def initialize
@parent_directives = []
@extends = Sass::Util::SubsetMap.new
+ @parent = nil
end
# If an exception is raised, this adds proper metadata to the backtrace.
@@ -124,12 +125,12 @@ def visit_extend(node)
end
sel = sseq.members
- parent.resolved_rules.members.each do |seq|
- if !seq.members.last.is_a?(Sass::Selector::SimpleSequence)
+ parent.resolved_rules.members.each do |member|
+ if !member.members.last.is_a?(Sass::Selector::SimpleSequence)
raise Sass::SyntaxError.new("#{seq} can't extend: invalid selector")
end
- @extends[sel] = Extend.new(seq, sel, node, @parent_directives.dup, :not_found)
+ @extends[sel] = Extend.new(member, sel, node, @parent_directives.dup, :not_found)
end
end
@@ -191,11 +191,13 @@ def visit_for(node)
end
end
+ HAS_CONTENT = true # :nodoc:
+
# Loads the function into the environment.
def visit_function(node)
env = Sass::Environment.new(@environment, node.options)
@environment.set_local_function(node.name,
- Sass::Callable.new(node.name, node.args, node.splat, env, node.children, !:has_content, "function"))
+ Sass::Callable.new(node.name, node.args, node.splat, env, node.children, !HAS_CONTENT, "function"))
[]
end
@@ -13,7 +13,13 @@ def initialize(build_source_mapping = false)
@line = 1
@offset = 1
@result = ""
- @source_mapping = Sass::Source::Map.new if build_source_mapping
+ @lstrip = false
+ @in_directive = nil
+ if build_source_mapping
+ @source_mapping = Sass::Source::Map.new
+ else
+ @source_mapping = nil
+ end
end
# Runs the visitor on `node`.
@@ -274,7 +280,6 @@ def visit_rule(node)
joined_rules.gsub!(/\s*\n\s*/, "#{line_separator}#{per_rule_indent}")
old_spaces = ' ' * @tabs
- spaces = ' ' * (@tabs + 1)
if node.style != :compressed
if node.options[:debug_info] && !@in_directive
visit(debug_info_rule(node.debug_info, node.options))
View
@@ -3,6 +3,7 @@
require 'enumerator'
require 'stringio'
require 'rbconfig'
+require 'uri'
require 'sass/root'
require 'sass/util/subset_map'
@@ -962,6 +963,15 @@ def method_missing(name, *args, &block)
end
end
+
+ URI_ESCAPE = URI.const_defined?(:DEFAULT_PARSER) ?
+ URI::DEFAULT_PARSER :
+ URI
+
+ def escape_uri(uri)
+ URI_ESCAPE.escape uri
+ end
+
private
# Calculates the memoization table for the Least Common Subsequence algorithm.
View
@@ -1,8 +1,4 @@
require 'date'
-
-# This is necessary for loading Sass when Haml is required in Rails 3.
-# Once the split is complete, we can remove it.
-require File.dirname(__FILE__) + '/../sass'
require 'sass/util'
module Sass
Oops, something went wrong.