diff --git a/CHANGES b/CHANGES index 081a3868fa4c2338fcf18c494e01bc15c28248e5..beb0007921b6b82ee023143ad55d22806acab724 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ + * Check initializer for session settings + * Add --checks option to list checks + ## 0.4.1 * Fix reported line numbers when using new Erubis parser diff --git a/lib/checks/check_session_settings.rb b/lib/checks/check_session_settings.rb index 4575d657b576cbbd72ad4f7b9e06706b8b8a4eac..02952d39bfe41e6bd2dde83b5c7fa15013c39671 100644 --- a/lib/checks/check_session_settings.rb +++ b/lib/checks/check_session_settings.rb @@ -3,11 +3,33 @@ require 'checks/base_check' class CheckSessionSettings < BaseCheck Checks.add self + SessionSettings = Sexp.new(:colon2, Sexp.new(:const, :ActionController), :Base) + def run_check settings = tracker.config[:rails] and tracker.config[:rails][:action_controller] and tracker.config[:rails][:action_controller][:session] + check_for_issues settings + + if tracker.initializers["session_store.rb"] + process tracker.initializers["session_store.rb"] + end + end + + def process_attrasgn exp + if exp[1] == SessionSettings and exp[2] == :session= and + hash? exp[3][1] + + check_for_issues exp[3][1] + end + + exp + end + + private + + def check_for_issues settings if settings and hash? settings hash_iterate settings do |key, value| if symbol? key diff --git a/lib/processor.rb b/lib/processor.rb index a27c2798acd5956e7b1df1b9bc4ae62f4e76e26a..69e7a8fb7cf2a3a14bcb2ed10f53a96348c1c4fc 100644 --- a/lib/processor.rb +++ b/lib/processor.rb @@ -75,7 +75,7 @@ class Processor def process_initializer name, src res = BaseProcessor.new(@tracker).process src res = AliasProcessor.new.process res - @tracker.initializers[name] = res + @tracker.initializers[Pathname.new(name).basename.to_s] = res end #Process source for a library file