Skip to content

Commit

Permalink
Fixing AzureDevops title maxLength (#2292)
Browse files Browse the repository at this point in the history
* Fixing AzureDevops title maxLength

* Adding releasehistory and updating tests

* Update ReleaseHistory.md

Co-authored-by: Michael C. Fanning <michael.fanning@microsoft.com>
  • Loading branch information
eddynaka and michaelcfanning authored Feb 24, 2021
1 parent 8c08327 commit 093a286
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/ReleaseHistory.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SARIF Package Release History (SDK, Driver, Converters, and Multitool)

* FEATURE: `ConstructMultilineContextSnippet` will retrieve a few character after/before to prevent entire file when the file is one line only. [#2288](https://github.com/microsoft/sarif-sdk/pull/2288)
* BUGFIX: Fix AzureDevOps title maxLength. [#2292](https://github.com/microsoft/sarif-sdk/pull/2292)

## **v2.4.1** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/2.4.1) | [Driver](https://www.nuget.org/packages/Sarif.Driver/2.4.1) | [Converters](https://www.nuget.org/packages/Sarif.Converters/2.4.1) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/2.4.1) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/2.4.1)
* BREAKING: Move `transform` functionality into `rewrite` and delete redundant `transform` command. [#2252](https://github.com/microsoft/sarif-sdk/pull/2252)
* FEATURE: kind, level, insert, and remove options can now be added to from environment variables. [#2273](https://github.com/microsoft/sarif-sdk/pull/2273)
Expand Down
10 changes: 5 additions & 5 deletions src/Sarif.WorkItems/SarifWorkItemsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Microsoft.CodeAnalysis.Sarif.WorkItems
{
Expand All @@ -24,7 +24,7 @@ public static bool ShouldBeFiled(this Result result)
//
// Open: a sound analysis is 'open' indicating that the analysis requires
// more configuration or other data in order to produce a determination.
//
//
// Review: an open item which can't be automated, i.e., which requires a
// manual review to resolve.
return result.Kind == ResultKind.Fail ||
Expand All @@ -34,7 +34,7 @@ public static bool ShouldBeFiled(this Result result)
// Designations which are not appropriate for filing:
//
// Pass: the scan target explicitly passed analysis.
//
//
// Not applicable: analysis was skipped because it was not
// relevant to the scan target.
//
Expand Down Expand Up @@ -82,9 +82,9 @@ public static string CreateWorkItemTitle(this Run run)
firstResult.Level.ToString() + "]: " +
fullRuleId;

// In ADO, the title cannot be longer than 256 characters
// In ADO, the title cannot be longer than 255 characters
const string ellipsis = "...";
const int maxChars = 256;
const int maxChars = 255;
int remainingChars = maxChars - titlePrefix.Length - 6; // " ({0})".Length == 6

// We encapsulate logical names in apostrophes to help indicate they are a symbol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text;

using FluentAssertions;
Expand Down Expand Up @@ -60,7 +60,7 @@ public void SarifWorkItemExtensions_CreateWorkItemTitle_HandlesSingleResultWithR
[Fact]
public void SarifWorkItemExtensions_CreateWorkItemTitle_LongTitleFromUrl()
{
int maxLength = 256;
int maxLength = 255;
string ruleId = "TestRuleId";
string expectedTemplate = "[aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:Warning]: TestRuleId: Test Rule (in al...)";
string expected = $":Warning]: TestRuleId: Test Rule (in al" + new string('a', maxLength - expectedTemplate.Length) + "...)";
Expand Down Expand Up @@ -97,7 +97,7 @@ public void SarifWorkItemExtensions_CreateWorkItemTitle_LongTitleFromLogicalLoca
run.Results.Add(result);

// A logical location longer than 128 char is truncated with ellipses
int maxLength = 256;
int maxLength = 255;
string expectedTemplate = "[aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:Warning]: TestRuleId: Test Rule (in 'll...')";
string expected = $":Warning]: TestRuleId: Test Rule (in 'll" + new string('b', maxLength - expectedTemplate.Length) + "...')";
result.Locations[0].LogicalLocation.FullyQualifiedName = "ll" + new string('b', 1024);
Expand Down

0 comments on commit 093a286

Please sign in to comment.