@@ -150,27 +150,27 @@ def violations(self, src_path):
150150 """
151151 if not any (src_path .endswith (ext ) for ext in self .driver .supported_extensions ):
152152 return []
153+
153154 if src_path not in self .violations_dict :
154155 if self .reports :
155156 self .violations_dict = self .driver .parse_reports (self .reports )
156- else :
157- if self .driver_tool_installed is None :
158- self .driver_tool_installed = self .driver .installed ()
159- if not self .driver_tool_installed :
160- raise OSError (f"{ self .driver .name } is not installed" )
161- command = copy .deepcopy (self .driver .command )
162- if self .options :
163- for arg in self .options .split ():
164- command .append (arg )
165- if os .path .exists (src_path ):
166- command .append (src_path .encode (sys .getfilesystemencoding ()))
167-
168- output = execute (command , self .driver .exit_codes )
169- if self .driver .output_stderr :
170- output = output [1 ]
171- else :
172- output = output [0 ]
173- self .violations_dict .update (self .driver .parse_reports ([output ]))
157+ return self .violations_dict [src_path ]
158+
159+ if self .driver_tool_installed is None :
160+ self .driver_tool_installed = self .driver .installed ()
161+ if not self .driver_tool_installed :
162+ msg = f"{ self .driver .name } is not installed"
163+ raise OSError (msg )
164+ command = copy .deepcopy (self .driver .command )
165+ if self .options :
166+ for arg in self .options .split ():
167+ command .append (arg )
168+ if os .path .exists (src_path ):
169+ command .append (src_path .encode (sys .getfilesystemencoding ()))
170+
171+ stdout , stderr = execute (command , self .driver .exit_codes )
172+ output = stderr if self .driver .output_stderr else stdout
173+ self .violations_dict .update (self .driver .parse_reports ([output ]))
174174
175175 return self .violations_dict [src_path ]
176176
0 commit comments