@Override public void afterCheckProject(@NonNull Context context) { if (mLocation != null && !mIgnore) { String message = "Potentially insecure random numbers on Android 4.3 and older. " + "Read " + BLOG_URL + " for more info."; context.report(ISSUE, mLocation, message); } } }
@Override public void afterCheckProject(@NonNull Context context) { if (mAlwaysFields != null && !mHasIfRoomRefs) { for (Location location : mAlwaysFields) { context.report(ISSUE, location, "Prefer \"`SHOW_AS_ACTION_IF_ROOM`\" instead of \"`SHOW_AS_ACTION_ALWAYS`\""); } } }
@Override public void afterCheckProject(@NonNull Context context) { if (mAlwaysFields != null && !mHasIfRoomRefs) { for (Location location : mAlwaysFields) { context.report(ISSUE, location, "Prefer \"`SHOW_AS_ACTION_IF_ROOM`\" instead of \"`SHOW_AS_ACTION_ALWAYS`\""); } } }
@Override public void afterCheckProject(@NonNull Context context) { if (mLocation != null && !mIgnore) { String message = "Potentially insecure random numbers on Android 4.3 and older. " + "Read " + BLOG_URL + " for more info."; context.report(ISSUE, mLocation, message); } } }
@Override public void afterCheckProject(@NonNull Context context) { if (mGetTokenCallSite != null && !mIsOnTokenRefreshDefined) { context.report( MISSING_TOKEN_REFRESH, mGetTokenContext.getLocation(mGetTokenCallSite), "getToken() called without defining onTokenRefresh callback."); } }
private void reportMap(Context context, Issue issue, Map<String, Location> map) { if (map != null) { for (Map.Entry<String, Location> entry : map.entrySet()) { Location location = entry.getValue(); String name = entry.getKey(); String message = mDescriptions.get(name); if (location == null) { location = Location.create(context.getProject().getDir()); } // We were prepending locations, but we want to prefer the base folders location = Location.reverse(location); context.report(issue, location, message); } } }
private void reportMap(Context context, Issue issue, Map<String, Location> map) { if (map != null) { for (Map.Entry<String, Location> entry : map.entrySet()) { Location location = entry.getValue(); String name = entry.getKey(); String message = mDescriptions.get(name); if (location == null) { location = Location.create(context.getProject().getDir()); } // We were prepending locations, but we want to prefer the base folders location = Location.reverse(location); context.report(issue, location, message); } } }
/** * Check that launcher icons are PNG or JPEG */ private static void checkLauncherIconFormat(Context context, File file) { String path = file.getPath(); if (endsWithIgnoreCase(path, DOT_PNG) || endsWithIgnoreCase(path, DOT_JPEG)) { return; } Location location = Location.create(file); String message = "Launcher icons must be in PNG format"; context.report(ICON_LAUNCHER_FORMAT, location, message); }
@Override public void afterCheckProject(@NonNull Context context) { if (mPendingErrors != null) { for (Pair<String,Location> pair : mPendingErrors) { String inflatedLayout = pair.getFirst(); if (mLayoutsWithRootLayoutParams == null || !mLayoutsWithRootLayoutParams.contains(inflatedLayout)) { // No root layout parameters on the inflated layout: no need to complain continue; } Location location = pair.getSecond(); context.report(ISSUE, location, ERROR_MESSAGE); } } }
@Override public void afterCheckProject(@NonNull Context context) { if (mPendingErrors != null) { for (Pair<String,Location> pair : mPendingErrors) { String inflatedLayout = pair.getFirst(); if (mLayoutsWithRootLayoutParams == null || !mLayoutsWithRootLayoutParams.contains(inflatedLayout)) { // No root layout parameters on the inflated layout: no need to complain continue; } Location location = pair.getSecond(); context.report(ISSUE, location, ERROR_MESSAGE); } } }
@Override public void afterCheckProject(@NonNull Context context) { if (mUsesRtlAttributes && mEnabledRtlSupport == null && rtlApplies(context)) { List<File> manifestFile = context.getMainProject().getManifestFiles(); if (!manifestFile.isEmpty()) { Location location = Location.create(manifestFile.get(0)); context.report(ENABLED, location, "The project references RTL attributes, but does not explicitly enable " + "or disable RTL support with `android:supportsRtl` in the manifest"); } } }
@Override public void afterCheckProject(@NonNull Context context) { if (mUsesRtlAttributes && mEnabledRtlSupport == null && rtlApplies(context)) { List<File> manifestFile = context.getMainProject().getManifestFiles(); if (!manifestFile.isEmpty()) { Location location = Location.create(manifestFile.get(0)); context.report(ENABLED, location, "The project references RTL attributes, but does not explicitly enable " + "or disable RTL support with `android:supportsRtl` in the manifest"); } } }
private static void validateCordovaVersion(@NonNull Context context, @NonNull GradleVersion cordovaVersion, Location location) { // All cordova versions below 4.1.1 are considered vulnerable. if (!cordovaVersion.isAtLeast(4, 1, 1)) { String message = String.format( "You are using a vulnerable version of Cordova: %1$s", cordovaVersion.toString()); context.report(ISSUE, location, message); } }
@Override public void afterCheckProject(@NonNull Context context) { if (mPendingFields != null) { for (List<Pair<String, Location>> list : mPendingFields.values()) { for (Pair<String, Location> pair : list) { String message = pair.getFirst(); Location location = pair.getSecond(); context.report(INLINED, location, message); } } } super.afterCheckProject(context); }
private static void report(Context context, Issue issue, Handle handle, String message) { Location location = handle.resolve(); Object clientData = handle.getClientData(); if (clientData instanceof Node) { if (context.getDriver().isSuppressed(null, issue, (Node) clientData)) { return; } } context.report(issue, location, message); }
private static void report(Context context, Issue issue, Handle handle, String message) { Location location = handle.resolve(); Object clientData = handle.getClientData(); if (clientData instanceof Node) { if (context.getDriver().isSuppressed(null, issue, (Node) clientData)) { return; } } context.report(issue, location, message); }
@Override public void report(@NonNull Issue issue, @NonNull Location location, @NonNull String message) { if (driver.isSuppressed(this, issue, javaFile)) { return; } super.report(issue, location, message); }
@Override public void beforeCheckProject(@NonNull Context context) { mApiDatabase = ApiLookup.get(context.getClient()); // We can't look up the minimum API required by the project here: // The manifest file hasn't been processed yet in the -before- project hook. // For now it's initialized lazily in getMinSdk(Context), but the // lint infrastructure should be fixed to parse manifest file up front. if (mApiDatabase == null && !mWarnedMissingDb) { mWarnedMissingDb = true; context.report(IssueRegistry.LINT_ERROR, Location.create(context.file), "Can't find API database; API check not performed"); } }
public void report( @NonNull Issue issue, @Nullable PsiElement scope, @NonNull Location location, @NonNull String message) { if (scope != null && driver.isSuppressed(this, issue, scope)) { return; } super.report(issue, location, message); }
@Override public void afterCheckProject(@NonNull Context context) { // Don't report issues on libraries if (context.getProject() == context.getMainProject() && !context.getMainProject().isLibrary() && mApplicationTagHandle != null) { if (!mSuppress && mHasNativeLibs) { context.report(ISSUE, mApplicationTagHandle.resolve(), "Missing attribute android:extractNativeLibs=\"false\"" + " on the `<application>` tag."); } } }