Skip to content

Commit 3604d51

Browse files
committed
[Xamarin.Android.Build.Tasks] Remove Unsupported Lint Checks
If a user provides lint checks which are not supported by the current lint version it will error. Invalid id or ategory "StatckFieldLeak" This is normally ok. But in our build system we sometimes end up on a bot which has an older version of lint. And in this case the test fails, which in reality it should ignore the id we are trying to use. So this commit addds some validation to the Disabled and Enabled checks. If its not supported we will remove the check and issue a warning.
1 parent 5c75043 commit 3604d51

File tree

1 file changed

+21
-1
lines changed
  • src/Xamarin.Android.Build.Tasks/Tasks

1 file changed

+21
-1
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/Lint.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public Lint ()
174174
{ "MissingSuperCall", new Version (26, 1, 1) },
175175
};
176176

177-
static readonly Regex lintVersionRegex = new Regex (@"version[\t\s]+(?<version>[\d\.]+)");
177+
static readonly Regex lintVersionRegex = new Regex (@"version[\t\s]+(?<version>[\d\.]+)", RegexOptions.Compiled);
178178

179179
public override bool Execute ()
180180
{
@@ -205,6 +205,26 @@ public override bool Execute ()
205205
Log.LogDebugTaskItems (" LibraryDirectories:", LibraryDirectories);
206206
Log.LogDebugTaskItems (" LibraryJars:", LibraryJars);
207207

208+
foreach (var issue in DisabledIssuesByVersion) {
209+
if (lintToolVersion < issue.Value) {
210+
Regex issueReplaceRegex = new Regex ($"{issue.Key}(,)?");
211+
if (!string.IsNullOrEmpty (DisabledIssues) && DisabledIssues.Contains (issue.Key)) {
212+
var match = issueReplaceRegex.Match (DisabledIssues);
213+
if (match.Success) {
214+
DisabledIssues = DisabledIssues.Replace (match.Value, string.Empty);
215+
Log.LogWarning ($"Removing {issue.Key} from DisabledIssues. Lint {lintToolVersion} does not support this check.");
216+
}
217+
}
218+
if (!string.IsNullOrEmpty (EnabledIssues) && EnabledIssues.Contains (issue.Key)) {
219+
var match = issueReplaceRegex.Match (EnabledIssues);
220+
if (match.Success) {
221+
EnabledIssues = EnabledIssues.Replace (match.Value, string.Empty);
222+
Log.LogWarning ($"Removing {issue.Key} from EnabledIssues. Lint {lintToolVersion} does not support this check.");
223+
}
224+
}
225+
}
226+
}
227+
208228
base.Execute ();
209229

210230
return !Log.HasLoggedErrors;

0 commit comments

Comments
 (0)