@@ -23,7 +23,7 @@ class Fixer:
2323 """
2424
2525 @classmethod
26- def fix_module (cls , module , reports , config ): # pylint: disable=unused-argument
26+ def fix_module (cls , module , reports , config , sourcefile ): # pylint: disable=unused-argument
2727 """
2828 Call `fix_module` for all rules and apply the transformations.
2929 """
@@ -33,14 +33,14 @@ def fix_module(cls, module, reports, config): # pylint: disable=unused-argument
3333 return module
3434
3535 @classmethod
36- def fix_subroutine (cls , subroutine , reports , config ):
36+ def fix_subroutine (cls , subroutine , reports , config , sourcefile ):
3737 """
3838 Call `fix_subroutine` for all rules and apply the transformations.
3939 """
4040 mapper = {}
4141 for report in reports :
4242 rule_config = config [report .rule .__name__ ]
43- mapper .update (report .rule .fix_subroutine (subroutine , report , rule_config ) or {})
43+ mapper .update (report .rule .fix_subroutine (subroutine , report , rule_config , sourcefile ) or {})
4444
4545 if mapper :
4646 # Apply the changes and invalidate source objects
@@ -87,10 +87,10 @@ def fix(cls, ast, reports, config):
8787 # Depth-first traversal
8888 if hasattr (ast , 'subroutines' ) and ast .subroutines is not None :
8989 for routine in ast .subroutines :
90- cls .fix_subroutine (routine , reports , config )
90+ cls .fix_subroutine (routine , reports , config , ast )
9191 if hasattr (ast , 'modules' ) and ast .modules is not None :
9292 for module in ast .modules :
93- cls .fix_module (module , reports , config )
93+ cls .fix_module (module , reports , config , ast )
9494
9595 cls .fix_sourcefile (ast , reports , config )
9696
@@ -99,18 +99,18 @@ def fix(cls, ast, reports, config):
9999 # Depth-first traversal
100100 if hasattr (ast , 'subroutines' ) and ast .subroutines is not None :
101101 for routine in ast .subroutines :
102- cls .fix_subroutine (routine , reports , config )
102+ cls .fix_subroutine (routine , reports , config , ast )
103103
104- cls .fix_module (ast , reports , config )
104+ cls .fix_module (ast , reports , config , ast )
105105
106106 # Fix on subroutine level
107107 elif isinstance (ast , Subroutine ):
108108 # Depth-first traversal
109109 if hasattr (ast , 'members' ) and ast .members is not None :
110110 for routine in ast .members :
111- cls .fix_subroutine (routine , reports , config )
111+ cls .fix_subroutine (routine , reports , config , ast )
112112
113- cls .fix_subroutine (ast , reports , config )
113+ cls .fix_subroutine (ast , reports , config , ast )
114114
115115 return ast
116116
0 commit comments