| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Top-level presubmit script for Chromium. | 5 """Top-level presubmit script for Chromium. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 2140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 return [] | 2151 return [] |
| 2152 | 2152 |
| 2153 return [output_api.PresubmitPromptWarning(""" | 2153 return [output_api.PresubmitPromptWarning(""" |
| 2154 Use of => operator detected in: | 2154 Use of => operator detected in: |
| 2155 %s | 2155 %s |
| 2156 Please ensure your code does not run on iOS9 (=> (arrow) does not work there). | 2156 Please ensure your code does not run on iOS9 (=> (arrow) does not work there). |
| 2157 https://chromium.googlesource.com/chromium/src/+/master/docs/es6_chromium.md#Arr
ow-Functions | 2157 https://chromium.googlesource.com/chromium/src/+/master/docs/es6_chromium.md#Arr
ow-Functions |
| 2158 """ % "\n".join(" %s:%d\n" % line for line in arrow_lines))] | 2158 """ % "\n".join(" %s:%d\n" % line for line in arrow_lines))] |
| 2159 | 2159 |
| 2160 | 2160 |
| 2161 def _CheckForRelativeIncludes(input_api, output_api): | |
| 2162 from cpp_checker import CppChecker | |
| 2163 | |
| 2164 bad_files = {} | |
| 2165 for f in input_api.AffectedFiles(include_deletes=False): | |
| 2166 if (f.LocalPath().startswith('third_party') and | |
| 2167 not f.LocalPath().startswith('third_party/WebKit') and | |
| 2168 not f.LocalPath().startswith('third_party\\WebKit')): | |
| 2169 continue | |
| 2170 | |
| 2171 if not CppChecker.IsCppFile(f.LocalPath()): | |
| 2172 continue | |
| 2173 | |
| 2174 relative_includes = [line for line_num, line in f.ChangedContents() | |
| 2175 if "#include" in line and "../" in line] | |
| 2176 bad_files[f.LocalPath()] = relative_includes | |
| 2177 | |
| 2178 if not bad_files: | |
| 2179 return [] | |
| 2180 | |
| 2181 error_descriptions = [] | |
| 2182 for file_path, bad_lines in bad_files.iteritems(): | |
| 2183 error_description = file_path | |
| 2184 for line in bad_lines: | |
| 2185 error_description += '\n ' + line | |
| 2186 error_descriptions.append(error_description) | |
| 2187 | |
| 2188 results = [] | |
| 2189 results.append(output_api.PresubmitError( | |
| 2190 'You added one or more relative #include paths (including "../").\n' | |
| 2191 'These shouldn\'t be used because they can be used to include headers\n' | |
| 2192 'from code that\'s not correctly specified as a dependency in the\n' | |
| 2193 'relevant BUILD.gn file(s).', | |
| 2194 error_descriptions)) | |
| 2195 | |
| 2196 return results | |
| 2197 | |
| 2198 def _AndroidSpecificOnUploadChecks(input_api, output_api): | 2161 def _AndroidSpecificOnUploadChecks(input_api, output_api): |
| 2199 """Groups checks that target android code.""" | 2162 """Groups checks that target android code.""" |
| 2200 results = [] | 2163 results = [] |
| 2201 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) | 2164 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) |
| 2202 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) | 2165 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) |
| 2203 results.extend(_CheckAndroidToastUsage(input_api, output_api)) | 2166 results.extend(_CheckAndroidToastUsage(input_api, output_api)) |
| 2204 results.extend(_CheckAndroidTestAnnotationUsage(input_api, output_api)) | 2167 results.extend(_CheckAndroidTestAnnotationUsage(input_api, output_api)) |
| 2205 return results | 2168 return results |
| 2206 | 2169 |
| 2207 | 2170 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2249 results.extend(_CheckNoDeprecatedJs(input_api, output_api)) | 2212 results.extend(_CheckNoDeprecatedJs(input_api, output_api)) |
| 2250 results.extend(_CheckParseErrors(input_api, output_api)) | 2213 results.extend(_CheckParseErrors(input_api, output_api)) |
| 2251 results.extend(_CheckForIPCRules(input_api, output_api)) | 2214 results.extend(_CheckForIPCRules(input_api, output_api)) |
| 2252 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 2215 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
| 2253 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 2216 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
| 2254 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) | 2217 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) |
| 2255 results.extend(_CheckJavaStyle(input_api, output_api)) | 2218 results.extend(_CheckJavaStyle(input_api, output_api)) |
| 2256 results.extend(_CheckIpcOwners(input_api, output_api)) | 2219 results.extend(_CheckIpcOwners(input_api, output_api)) |
| 2257 results.extend(_CheckUselessForwardDeclarations(input_api, output_api)) | 2220 results.extend(_CheckUselessForwardDeclarations(input_api, output_api)) |
| 2258 results.extend(_CheckForRiskyJsFeatures(input_api, output_api)) | 2221 results.extend(_CheckForRiskyJsFeatures(input_api, output_api)) |
| 2259 results.extend(_CheckForRelativeIncludes(input_api, output_api)) | |
| 2260 | 2222 |
| 2261 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 2223 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 2262 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 2224 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 2263 input_api, output_api, | 2225 input_api, output_api, |
| 2264 input_api.PresubmitLocalPath(), | 2226 input_api.PresubmitLocalPath(), |
| 2265 whitelist=[r'^PRESUBMIT_test\.py$'])) | 2227 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 2266 return results | 2228 return results |
| 2267 | 2229 |
| 2268 | 2230 |
| 2269 def _CheckPatchFiles(input_api, output_api): | 2231 def _CheckPatchFiles(input_api, output_api): |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2508 output_api, | 2470 output_api, |
| 2509 json_url='http://chromium-status.appspot.com/current?format=json')) | 2471 json_url='http://chromium-status.appspot.com/current?format=json')) |
| 2510 | 2472 |
| 2511 results.extend( | 2473 results.extend( |
| 2512 input_api.canned_checks.CheckPatchFormatted(input_api, output_api)) | 2474 input_api.canned_checks.CheckPatchFormatted(input_api, output_api)) |
| 2513 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2475 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
| 2514 input_api, output_api)) | 2476 input_api, output_api)) |
| 2515 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2477 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
| 2516 input_api, output_api)) | 2478 input_api, output_api)) |
| 2517 return results | 2479 return results |
| OLD | NEW |