MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / analyze

Method analyze

client/tool/findbugs.py:105–134  ·  view source on GitHub ↗
(self, params)

Source from the content-addressed store, hash-verified

103 return True
104
105 def analyze(self, params):
106
107 source_dir = params["source_dir"]
108 enabled_rules = params["rules"]
109 error_output = os.path.join(os.path.curdir, "findbugs_result.xml")
110
111 # analyze step
112 tool_name = "findbugs"
113 visitors = RulesToVisitors(tool_name).get_needed_visitors(enabled_rules)
114 # findbugs的兼容性:这里需要使用原生的java -jar xx才能适配win|linux下的按指定检测器检测(使用wrapper脚本会有问题)
115 scan_cmd = [
116 "java",
117 "-jar",
118 os.path.join(os.environ["FINDBUGS_HOME"], "lib", "findbugs.jar"),
119 "-textui",
120 "-low",
121 "-exitcode",
122 "-nested:false",
123 "-xml:withMessages",
124 ]
125 if visitors:
126 scan_cmd.append("-visitors")
127 scan_cmd.append(",".join(visitors))
128 scan_cmd.extend(["-output", error_output, source_dir])
129 SubProcController(scan_cmd).wait()
130
131 # format step
132 ctf = ClassToFilename(source_dir)
133 items = Findbugs.data_handle(error_output, enabled_rules, ctf)
134 return items
135
136 @staticmethod
137 def data_handle(error_output, enabled_rules, ctf):

Callers

nothing calls this directly

Calls 4

RulesToVisitorsClass · 0.85
ClassToFilenameClass · 0.85
get_needed_visitorsMethod · 0.80
data_handleMethod · 0.45

Tested by

no test coverage detected