Примеры ошибок, обнаруженных с помощью диагностики V3127
V3127. Two similar code fragments were found. Perhaps, this is a typo and 'X' variable should be used instead of 'Y'.
Media Portal 2
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'AllocinebId' variable should be used instead of 'CinePassionId' MovieRelationshipExtractor.cs 126
if (movie.CinePassionId > 0)
ids.Add(ExternalIdentifierAspect.SOURCE_CINEPASSION,
movie.CinePassionId.ToString());
if (movie.CinePassionId > 0) // <=
ids.Add(ExternalIdentifierAspect.SOURCE_ALLOCINE,
movie.AllocinebId.ToString());
Similar errors can be found in some other places:
- V3127 Two similar code fragments were found. Perhaps, this is a typo and 'attrY' variable should be used instead of 'attrX' AbstractSortByComparableValueAttribute.cs 94
- V3127 Two similar code fragments were found. Perhaps, this is a typo and 'X' variable should be used instead of 'Y' Point2DList.cs 935
- V3127 Two similar code fragments were found. Perhaps, this is a typo and 'Y' variable should be used instead of 'X' PointAnimation.cs 125
Roslyn Analyzers
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'leadingTrivia' variable should be used instead of 'trailingTrivia' UseLiteralsWhereAppropriate.Fixer.cs 76
private async Task<Document> ToConstantDeclarationAsync(...)
{
....
if (leadingTrivia.Count == 0 && trailingTrivia.Count == 0)
{
leadingTrivia = leadingTrivia.AddRange(modifier.LeadingTrivia);
trailingTrivia = trailingTrivia.AddRange(modifier.TrailingTrivia);
}
else
{
trailingTrivia = trailingTrivia.AddRange(modifier.LeadingTrivia); // <=
trailingTrivia = trailingTrivia.AddRange(modifier.TrailingTrivia); // <=
....
}
....
}
Telerik UI for UWP
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'emptyIconContainer' variable should be used instead of 'filledIconContainer' RadRatingItem.cs 240
protected override void OnApplyTemplate()
{
....
this.filledIconContainer = this.GetTemplateChild("FilledIconContainer")
as Border;
if (this.filledIconContainer == null)
{
throw new MissingTemplatePartException("FilledIconContainer",
typeof(Border));
}
this.emptyIconContainer = this.GetTemplateChild(EmptyIconContainer")
as Border;
if (this.filledIconContainer == null) // <=
{
throw new MissingTemplatePartException("EmptyIconContainer",
typeof(Border));
}
this.Initialize();
}
Orchard CMS
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'AccessTokenSecret' variable should be used instead of 'ConsumerSecret' TwitterClientMessageHandler.cs 52
public async Task ConfigureOAuthAsync(HttpRequestMessage request)
{
....
if (!string.IsNullOrWhiteSpace(settings.ConsumerSecret))
settings.ConsumerSecret =
protrector.Unprotect(settings.ConsumerSecret);
if (!string.IsNullOrWhiteSpace(settings.ConsumerSecret))
settings.AccessTokenSecret =
protrector.Unprotect(settings.AccessTokenSecret);
....
}
OpenCvSharp
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'window' variable should be used instead of 'src2' Cv2_imgproc.cs 1547
public static Point2d PhaseCorrelateRes(....)
{
if (src1 == null)
throw new ArgumentNullException(nameof(src1));
if (src2 == null)
throw new ArgumentNullException(nameof(src2));
if (window == null)
throw new ArgumentNullException(nameof(src2)); // <=
....
}
RavenDB
V3127 Two similar code fragments were found. Perhaps, this is a typo. SmugglerResult.cs(256), SmugglerResult.cs(253) Raven.Client
public override void WriteTo(StringBuilder writer)
{
....
if (SqlConnectionStringsUpdated)
json[nameof(SqlConnectionStringsUpdated)] = SqlConnectionStringsUpdated;
if (ClientConfigurationUpdated)
json[nameof(ClientConfigurationUpdated)] = ClientConfigurationUpdated;
if (ConflictSolverConfigUpdated)
json[nameof(ConflictSolverConfigUpdated)] = ClientConfigurationUpdated;
if (PeriodicBackupsUpdated)
json[nameof(PeriodicBackupsUpdated)] = PeriodicBackupsUpdated;
if (ExternalReplicationsUpdated)
json[nameof(ExternalReplicationsUpdated)] = ExternalReplicationsUpdated;
....
}
OpenRA
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'oldMapRamp' variable should be used instead of 'oldMapHeight' Map.cs 964
public void Resize(int width, int height)
{
var oldMapTiles = Tiles;
var oldMapResources = Resources;
var oldMapHeight = Height;
var oldMapRamp = Ramp;
var newSize = new Size(width, height);
....
Tiles = CellLayer.Resize(oldMapTiles, newSize, oldMapTiles[MPos.Zero]);
Resources = CellLayer.Resize(
oldMapResources,
newSize,
oldMapResources[MPos.Zero]
);
Height = CellLayer.Resize(oldMapHeight, newSize, oldMapHeight[MPos.Zero]);
Ramp = CellLayer.Resize(oldMapRamp, newSize, oldMapHeight[MPos.Zero]);
....
}
PeachPie
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'NO_RES_RANGE' variable should be used instead of 'NO_PRIV_RANGE' Filter.cs 771
public static PhpValue filter_var(....)
{
....
if ((flags & (int)FilterFlag.NO_PRIV_RANGE) == (int)FilterFlag.NO_PRIV_RANGE)
{
throw new NotImplementedException();
}
if ((flags & (int)FilterFlag.NO_PRIV_RANGE) == (int)FilterFlag.NO_RES_RANGE)
{
throw new NotImplementedException();
}
....
}
DotNetNuke
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'txtHeight' variable should be used instead of 'txtWidth' CKEditorOptions.ascx.cs 2477
private void SaveModuleSettings()
{
....
if (Utility.IsUnit(this.txtWidth.Text))
{
moduleController.UpdateModuleSetting(this.ModuleId,
$"{key}{SettingConstants.WIDTH}",
this.txtWidth.Text); // <=
}
if (Utility.IsUnit(this.txtHeight.Text))
{
moduleController.UpdateModuleSetting(this.ModuleId,
$"{key}{SettingConstants.HEIGHT}",
this.txtWidth.Text); // <=
}
....
}
Piranha
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'news' variable should be used instead of 'blog' CommentTests.cs 94
public override async Task InitializeAsync()
{
using (var api = CreateApi())
{
....
// Add archive
var blog = await BlogArchive.CreateAsync(api);
blog.Id = BLOG_ID;
blog.SiteId = SITE_ID;
blog.Title = "Blog";
blog.EnableComments = true;
blog.Published = DateTime.Now;
await api.Pages.SaveAsync(blog);
var news = await BlogArchive.CreateAsync(api);
news.Id = NEWS_ID;
news.SiteId = SITE_ID;
news.Title = "News";
blog.EnableComments = true; // <=
news.Published = DateTime.Now;
await api.Pages.SaveAsync(news);
....
}
}
Orchard Core
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'AccessTokenSecret' variable should be used instead of 'ConsumerSecret' TwitterClientMessageHandler.cs 51
public async Task ConfigureOAuthAsync(HttpRequestMessage request)
{
var container = await _siteService.GetSiteSettingsAsync();
var settings = container.As<TwitterSettings>();
var protrector = _dataProtectionProvider
.CreateProtector(TwitterConstants
.Features
.Twitter);
var queryString = request.RequestUri.Query;
if (!string.IsNullOrWhiteSpace(settings.ConsumerSecret))
settings.ConsumerSecret =
protrector.Unprotect(settings.ConsumerSecret);
if (!string.IsNullOrWhiteSpace(settings.ConsumerSecret))
settings.AccessTokenSecret =
protrector.Unprotect(settings.AccessTokenSecret);
....
}
Discord.NET
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'TargetApplicationId' variable should be used instead of 'TargetUserId' DiscordRestApiClient.cs 1759
public async Task<InviteMetadata>
CreateChannelInviteAsync(ulong channelId,
CreateChannelInviteParams args,
RequestOptions options = null)
{
....
if (args.TargetType.Value == TargetUserType.Stream)
Preconditions.GreaterThan(args.TargetUserId, 0,
nameof(args.TargetUserId)); // <=
if (args.TargetType.Value == TargetUserType.EmbeddedApplication)
Preconditions.GreaterThan(args.TargetApplicationId, 0,
nameof(args.TargetUserId)); // <=
....
}
GrandNode
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'ReservedQuantity' variable should be used instead of 'StockQuantity' InventoryManageService.cs 244
private async Task ReverseBookedInventory(Product product,
InventoryJournal inventoryJournal)
{
....
combination.StockQuantity
= combination.WarehouseInventory.Sum(x => x.StockQuantity);
combination.ReservedQuantity
= combination.WarehouseInventory.Sum(x => x.StockQuantity);
product.StockQuantity
= product.ProductAttributeCombinations.Sum(x => x.StockQuantity);
product.ReservedQuantity
= product.ProductAttributeCombinations.Sum(x => x.ReservedQuantity);
....
}
RavenDB
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'JournalStoragePath' variable should be used instead of 'DataDirectory' RestoreResult.cs 24
public override DynamicJsonValue ToJson()
{
var json = base.ToJson();
json[nameof(DataDirectory)] = DataDirectory;
json[nameof(JournalStoragePath)] = DataDirectory; // <=
json[nameof(SnapshotRestore)] = SnapshotRestore.ToJson();
return json;
}
Garnet
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'currentConfigEpoch' variable should be used instead of 'lastVotedConfigEpoch' ClusterConfig.cs 116
public ClusterConfig InitializeLocalWorker(....)
{
Worker[] newWorkers = new Worker[workers.Length];
Array.Copy(workers, newWorkers, workers.Length);
newWorkers[1].address = address;
newWorkers[1].port = port;
newWorkers[1].nodeid = nodeId;
newWorkers[1].configEpoch = configEpoch;
newWorkers[1].lastVotedConfigEpoch = currentConfigEpoch; // <=
newWorkers[1].lastVotedConfigEpoch = lastVotedConfigEpoch; // <=
newWorkers[1].role = role;
newWorkers[1].replicaOfNodeId = replicaOfNodeId;
newWorkers[1].replicationOffset = 0;
newWorkers[1].hostname = hostname;
return new ClusterConfig(slotMap, newWorkers);
}
Starlight
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'bottomRight' variable should be used instead of 'topRight' TMP_TextInfoDebugTool.cs 313
void DrawWordBounds()
{
topLeft = m_Transform.TransformPoint(new (topLeft.x,
maxAscender, 0));
bottomLeft = m_Transform.TransformPoint(new (bottomLeft.x,
minDescender, 0));
bottomRight = m_Transform.TransformPoint(new (currentCharInfo.topRight.x,
minDescender, 0));
topRight = m_Transform.TransformPoint(new (currentCharInfo.topRight.x,
maxAscender, 0));
}
ScreenToGif
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'right' variable should be used instead of 'left' Insert.xaml.cs 303
private void Window_Loaded(object sender, RoutedEventArgs e)
{
....
CanvasSizeTextBlock.Text = $"{right.PixelWidth} × " +
$"{right.PixelHeight} • " +
$"{Math.Round(left.DpiX, 0)} " + // <=
$"{LocalizationHelper.Get("S.Resize.Dpi")}";
LeftImageSizeTextBlock.Text = $"{left.PixelWidth} × " +
$"{left.PixelHeight} • " +
$"{Math.Round(left.DpiX, 0)} " +
$"{LocalizationHelper.Get("S.Resize.Dpi")}";
....
}
ScreenToGif
V3127 Two similar code fragments were found. Perhaps, this is a typo and 'Bounds' variable should be used instead of 'NativeBounds' Troubleshoot.xaml.cs 86
if (monitor.NativeBounds.Top > top)
top = monitor.NativeBounds.Top;
if (monitor.Bounds.Left > left) // <=
left = monitor.NativeBounds.Left;
if (monitor.NativeBounds.Bottom < top + height)
top = monitor.NativeBounds.Bottom - height;
if (monitor.NativeBounds.Right < left + width)
left = monitor.NativeBounds.Right - width;