@Override public void afterCheckLibraryProject(@NonNull Context context) { if (!context.getProject().getReportIssues()) { // If this is a library project not being analyzed, ignore it return; } checkResourceFolder(context, context.getProject()); }
@Override public void afterCheckLibraryProject(@NonNull Context context) { if (!context.getProject().getReportIssues()) { // If this is a library project not being analyzed, ignore it return; } checkResourceFolders(context, context.getProject()); }
@Override public void afterCheckProject(@NonNull Context context) { if (!context.getProject().getReportIssues()) { // If this is a library project not being analyzed, ignore it return; } checkResourceFolders(context, context.getProject()); }
@Override public void afterCheckLibraryProject(@NonNull Context context) { if (!context.getProject().getReportIssues()) { // If this is a library project not being analyzed, ignore it return; } checkResourceFolder(context, context.getProject()); }
private static boolean isPrivate(Context context, ResourceType type, String name) { if (context.getProject().isGradleProject()) { ResourceVisibilityLookup lookup = context.getProject().getResourceVisibility(); return lookup.isPrivate(type, name); } return false; }
@Override public void afterCheckProject(@NonNull Context context) { checkResourceFolder(context, context.getProject()); }
@Override public void beforeCheckProject(@NonNull Context context) { Boolean dependsOnAppCompat = context.getProject().dependsOn(APPCOMPAT_LIB_ARTIFACT); mDependsOnAppCompat = dependsOnAppCompat != null && dependsOnAppCompat; }
@Override public void beforeCheckLibraryProject(@NonNull Context context) { // TODO: Make sure this doesn't wipe out the prefix for the remaining projects mPrefix = computeResourcePrefix(context.getProject()); }
@Override public void beforeCheckProject(@NonNull Context context) { Boolean dependsOnAppCompat = context.getProject().dependsOn(APPCOMPAT_LIB_ARTIFACT); mDependsOnAppCompat = dependsOnAppCompat != null && dependsOnAppCompat; }
@Override public void beforeCheckProject(@NonNull Context context) { mPrefix = computeResourcePrefix(context.getProject()); }
@Override public void afterCheckProject(@NonNull Context context) { checkResourceFolder(context, context.getProject()); }
@Override public void beforeCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { mNames = new HashSet<>(); } // Convention seen in various projects mIgnoreFile = context.file.getName().startsWith("donottranslate") || ResourceUsageModel.isAnalyticsFile(context.file); if (!context.getProject().getReportIssues()) { mIgnoreFile = true; } }
@Override public void beforeCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { mNames = new HashSet<String>(); } // Convention seen in various projects mIgnoreFile = context.file.getName().startsWith("donottranslate") //$NON-NLS-1$ || UnusedResourceDetector.isAnalyticsFile(context); if (!context.getProject().getReportIssues()) { mIgnoreFile = true; } }
private static boolean isModelOlderThan011(@NonNull Context context) { return LintUtils.isModelOlderThan(context.getProject(), 0, 11, 0); }
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); } } }
@Override public void run(@NonNull Context context) { if (!context.getProject().getReportIssues()) { // If this is a library project not being analyzed, ignore it return; } File file = context.file; if (isPrivateKeyFile(file)) { String fileName = file.getParentFile().getName() + File.separator + file.getName(); String message = String.format( "The `%1$s` file seems to be a private key file. " + "Please make sure not to embed this in your APK file.", fileName); context.report(ISSUE, Location.create(file), message); } }
@Override public void run(@NonNull Context context) { if (!context.getProject().getReportIssues()) { // If this is a library project not being analyzed, ignore it return; } File file = context.file; if (isPrivateKeyFile(file)) { String fileName = file.getParentFile().getName() + File.separator + file.getName(); String message = String.format( "The `%1$s` file seems to be a private key file. " + "Please make sure not to embed this in your APK file.", fileName); context.report(ISSUE, Location.create(file), message); } }
private static boolean isModelOlderThan011(@NonNull Context context) { return LintUtils.isModelOlderThan(context.getProject().getGradleProjectModel(), 0, 11, 0); }
@Override public void afterCheckProject(@NonNull Context context) { if (context.getProject() == context.getMainProject() && // Full analysis? Don't tie check to any specific Gradle DSL element context.getScope().contains(Scope.ALL_RESOURCE_FILES)) { checkConsistentPlayServices(context, null); checkConsistentSupportLibraries(context, null); checkConsistentWearableLibraries(context, null); } }
@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."); } } }