Merge pull request #7382 from Mailaender/stylecop-plus

Added support for StyleCop+
This commit is contained in:
Matthias Mailänder
2015-01-25 23:58:42 +01:00
21 changed files with 79 additions and 34 deletions

View File

@@ -45,8 +45,8 @@ namespace OpenRA.FileFormats
public static class AudLoader public static class AudLoader
{ {
static int[] indexAdjust = { -1, -1, -1, -1, 2, 4, 6, 8 }; static int[] indexAdjust = { -1, -1, -1, -1, 2, 4, 6, 8 };
static int[] stepTable = static int[] stepTable =
{ {
7, 8, 9, 10, 11, 12, 13, 14, 16, 7, 8, 9, 10, 11, 12, 13, 14, 16,
17, 19, 21, 23, 25, 28, 31, 34, 37, 17, 19, 21, 23, 25, 28, 31, 34, 37,
41, 45, 50, 55, 60, 66, 73, 80, 88, 41, 45, 50, 55, 60, 66, 73, 80, 88,
@@ -56,7 +56,7 @@ namespace OpenRA.FileFormats
1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749,
3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484,
7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289,
16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
}; };
static short DecodeSample(byte b, ref int index, ref int current) static short DecodeSample(byte b, ref int index, ref int current)

View File

@@ -43,7 +43,7 @@ namespace OpenRA.FileFormats
1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749,
3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484,
7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289,
16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
}; };
static short DecodeImaAdpcmSample(byte b, ref int index, ref int current) static short DecodeImaAdpcmSample(byte b, ref int index, ref int current)

View File

@@ -73,7 +73,7 @@ namespace OpenRA.FileFormats
/*var length2 = */stream.ReadUInt32(); /*var length2 = */stream.ReadUInt32();
/*var version = */stream.ReadUInt16(); /*var version = */stream.ReadUInt16();
videoFlags = stream.ReadUInt16(); videoFlags = stream.ReadUInt16();
Frames = stream.ReadUInt16(); Frames = stream.ReadUInt16();
Width = stream.ReadUInt16(); Width = stream.ReadUInt16();
Height = stream.ReadUInt16(); Height = stream.ReadUInt16();
@@ -129,7 +129,7 @@ namespace OpenRA.FileFormats
type = stream.ReadASCII(4); type = stream.ReadASCII(4);
} }
else else
throw new NotSupportedException("Vqa uses unknown Subtype : {0}".F(type)); throw new NotSupportedException("Vqa uses unknown Subtype: {0}".F(type));
} }
/*var length = */stream.ReadUInt16(); /*var length = */stream.ReadUInt16();
@@ -413,7 +413,7 @@ namespace OpenRA.FileFormats
if (IsHqVqa) if (IsHqVqa)
{ {
/* The VP?? chunks of the video file contains an array of instructions for /* The VP?? chunks of the video file contains an array of instructions for
* how the blocks of the finished frame will be filled with color data blocks * how the blocks of the finished frame will be filled with color data blocks
* contained in the CBF? chunks. * contained in the CBF? chunks.
*/ */
var p = 0; var p = 0;
@@ -424,7 +424,7 @@ namespace OpenRA.FileFormats
if (y >= blocks.Y) if (y >= blocks.Y)
break; break;
// The first 3 bits of the short determine the type of instruction with the rest being one or two parameters. // The first 3 bits of the short determine the type of instruction with the rest being one or two parameters.
var val = (int)origData[p++]; var val = (int)origData[p++];
val |= origData[p++] << 8; val |= origData[p++] << 8;
var para_A = val & 0x1fff; var para_A = val & 0x1fff;

View File

@@ -129,7 +129,7 @@ namespace OpenRA.FileFormats
// Decode each block of IMA ADPCM data in RawOutput // Decode each block of IMA ADPCM data in RawOutput
for (var block = 0; block < numBlocks; block++) for (var block = 0; block < numBlocks; block++)
{ {
// Each block starts with a initial state per-channel // Each block starts with a initial state per-channel
for (var c = 0; c < Channels; c++) for (var c = 0; c < Channels; c++)
{ {
predictor[c] = s.ReadInt16(); predictor[c] = s.ReadInt16();

View File

@@ -134,7 +134,7 @@ namespace OpenRA
public class Player public class Player
{ {
// Start-up information // Start-up information
public int ClientIndex; public int ClientIndex;
// The player name, not guaranteed to be unique. // The player name, not guaranteed to be unique.

View File

@@ -187,7 +187,7 @@ namespace OpenRA
default: default:
textStart = true; textStart = true;
break; break;
} }
} }
var t = line.Substring(cp); var t = line.Substring(cp);

View File

@@ -195,7 +195,7 @@ namespace OpenRA
switch (OrderString) switch (OrderString)
{ {
/* /*
* Format: * Format:
* u8: orderID. * u8: orderID.
* 0xFF: Full serialized order. * 0xFF: Full serialized order.

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Widgets
Lazy<TooltipContainerWidget> tooltipContainer; Lazy<TooltipContainerWidget> tooltipContainer;
[Translate] public string TooltipText; [Translate] public string TooltipText;
public Func<string> GetTooltipText; public Func<string> GetTooltipText;
// Equivalent to OnMouseUp, but without an input arg // Equivalent to OnMouseUp, but without an input arg
public Action OnClick = () => { }; public Action OnClick = () => { };

View File

@@ -21,17 +21,17 @@ namespace OpenRA.Mods.Cnc.Traits
[ActorReference] [ActorReference]
[Desc("Actor to spawn when the attack starts")] [Desc("Actor to spawn when the attack starts")]
public readonly string CameraActor = null; public readonly string CameraActor = null;
[Desc("Amount of time to keep the camera alive")] [Desc("Amount of time to keep the camera alive")]
public readonly int CameraRemoveDelay = 25; public readonly int CameraRemoveDelay = 25;
[Desc("Effect sequence to display")] [Desc("Effect sequence to display")]
public readonly string Effect = "ionsfx"; public readonly string Effect = "ionsfx";
public readonly string EffectPalette = "effect"; public readonly string EffectPalette = "effect";
[Desc("Which weapon to fire")] [Desc("Which weapon to fire")]
public readonly string Weapon = "IonCannon"; public readonly string Weapon = "IonCannon";
[Desc("Apply the weapon impact this many ticks into the effect")] [Desc("Apply the weapon impact this many ticks into the effect")]
public readonly int WeaponDelay = 7; public readonly int WeaponDelay = 7;

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
var turreted = self.TraitsImplementing<Turreted>() var turreted = self.TraitsImplementing<Turreted>()
.FirstOrDefault(t => t.Name == arm.Info.Turret); .FirstOrDefault(t => t.Name == arm.Info.Turret);
// Workaround for broken ternary operators in certain versions of mono (3.10 and // Workaround for broken ternary operators in certain versions of mono (3.10 and
// certain versions of the 3.8 series): https://bugzilla.xamarin.com/show_bug.cgi?id=23319 // certain versions of the 3.8 series): https://bugzilla.xamarin.com/show_bug.cgi?id=23319
if (turreted != null) if (turreted != null)
getFacing = () => turreted.TurretFacing; getFacing = () => turreted.TurretFacing;

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
var console = new StyleCopConsole(null, false, null, null, true); var console = new StyleCopConsole(null, false, null, null, true);
var project = new CodeProject(0, projectPath, new Configuration(null)); var project = new CodeProject(0, projectPath, new Configuration(null));
foreach (var filePath in Directory.GetFiles(projectPath, "*.cs", SearchOption.AllDirectories)) foreach (var filePath in Directory.GetFiles(projectPath, "*.cs", SearchOption.AllDirectories).Where(p => !p.Contains(".Designer")))
console.Core.Environment.AddSourceCode(project, filePath, null); console.Core.Environment.AddSourceCode(project, filePath, null);
console.ViolationEncountered += OnViolationEncountered; console.ViolationEncountered += OnViolationEncountered;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Activities
protected readonly int DragLength; protected readonly int DragLength;
protected readonly WPos StartDrag; protected readonly WPos StartDrag;
protected readonly WPos EndDrag; protected readonly WPos EndDrag;
protected State dockingState; protected State dockingState;
public HarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength) public HarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS) * Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var songWatcher = widget.GetOrNull<LogicTickerWidget>("SONG_WATCHER"); var songWatcher = widget.GetOrNull<LogicTickerWidget>("SONG_WATCHER");
if (songWatcher != null) if (songWatcher != null)
{ {
songWatcher.OnTick = () => songWatcher.OnTick = () =>
{ {
if (Sound.CurrentMusic == null || currentSong == Sound.CurrentMusic) if (Sound.CurrentMusic == null || currentSong == Sound.CurrentMusic)
return; return;

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
var options = new List<StatsDropDownOption> var options = new List<StatsDropDownOption>
{ {
new StatsDropDownOption new StatsDropDownOption
{ {
Title = "Basic", Title = "Basic",
IsSelected = () => basicStatsHeaders.Visible, IsSelected = () => basicStatsHeaders.Visible,
@@ -83,33 +83,33 @@ namespace OpenRA.Mods.RA.Widgets.Logic
DisplayStats(BasicStats); DisplayStats(BasicStats);
} }
}, },
new StatsDropDownOption new StatsDropDownOption
{ {
Title = "Economy", Title = "Economy",
IsSelected = () => economyStatsHeaders.Visible, IsSelected = () => economyStatsHeaders.Visible,
OnClick = () => OnClick = () =>
{ {
ClearStats(); ClearStats();
statsDropDown.GetText = () => "Economy"; statsDropDown.GetText = () => "Economy";
DisplayStats(EconomyStats); DisplayStats(EconomyStats);
} }
}, },
new StatsDropDownOption new StatsDropDownOption
{ {
Title = "Production", Title = "Production",
IsSelected = () => productionStatsHeaders.Visible, IsSelected = () => productionStatsHeaders.Visible,
OnClick = () => OnClick = () =>
{ {
ClearStats(); ClearStats();
statsDropDown.GetText = () => "Production"; statsDropDown.GetText = () => "Production";
DisplayStats(ProductionStats); DisplayStats(ProductionStats);
} }
}, },
new StatsDropDownOption new StatsDropDownOption
{ {
Title = "Combat", Title = "Combat",
IsSelected = () => combatStatsHeaders.Visible, IsSelected = () => combatStatsHeaders.Visible,
OnClick = () => OnClick = () =>
{ {
ClearStats(); ClearStats();
statsDropDown.GetText = () => "Combat"; statsDropDown.GetText = () => "Combat";
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ {
Title = "Earnings (graph)", Title = "Earnings (graph)",
IsSelected = () => earnedThisMinuteGraphHeaders.Visible, IsSelected = () => earnedThisMinuteGraphHeaders.Visible,
OnClick = () => OnClick = () =>
{ {
ClearStats(); ClearStats();
statsDropDown.GetText = () => "Earnings (graph)"; statsDropDown.GetText = () => "Earnings (graph)";

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS) * Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS) * Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.
@@ -271,7 +271,7 @@ namespace OpenRA.TilesetBuilder
bw.Write((uint)0); // filesize placeholder bw.Write((uint)0); // filesize placeholder
bw.Flush(); bw.Flush();
bw.Write((uint)ms.Position + 24); // image start bw.Write((uint)ms.Position + 24); // image start
bw.Write((uint)0); // 0 (32bits) bw.Write((uint)0); // 0 (32bits)
bw.Write((uint)0x2c730f8c); // magic? bw.Write((uint)0x2c730f8c); // magic?
bw.Write((uint)0); // flags start bw.Write((uint)0); // flags start
bw.Write((uint)0); // walk start bw.Write((uint)0); // walk start

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS) * Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
* see COPYING. * see COPYING.

View File

@@ -360,5 +360,35 @@
</Rules> </Rules>
<AnalyzerSettings /> <AnalyzerSettings />
</Analyzer> </Analyzer>
<Analyzer AnalyzerId="StyleCopPlus.StyleCopPlusRules">
<Rules>
<Rule Name="CheckAllowedIndentationCharacters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="CheckWhetherLastCodeLineIsEmpty">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="CodeLineMustNotBeLongerThan">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="MethodMustNotContainMoreLinesThan">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="AdvancedNamingRules">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers> </Analyzers>
</StyleCopSettings> </StyleCopSettings>

View File

@@ -9,6 +9,14 @@ if (!(Test-Path "nuget.exe"))
(New-Object System.Net.WebClient).DownloadFile("http://nuget.org/nuget.exe", $target) (New-Object System.Net.WebClient).DownloadFile("http://nuget.org/nuget.exe", $target)
} }
if (!(Test-Path "StyleCopPlus.dll"))
{
echo "Fetching StyleCopPlus from NuGet."
./nuget.exe install StyleCopPlus.MSBuild -Version 4.7.49.5
cp StyleCopPlus.MSBuild.4.7.49.5/tools/StyleCopPlus.dll .
rmdir StyleCopPlus.MSBuild.4.7.49.5 -Recurse
}
if (!(Test-Path "StyleCop.dll")) if (!(Test-Path "StyleCop.dll"))
{ {
echo "Fetching StyleCop files from NuGet." echo "Fetching StyleCop files from NuGet."

View File

@@ -3,6 +3,13 @@
# Die on any error for Travis CI to automatically retry: # Die on any error for Travis CI to automatically retry:
set -e set -e
if [ ! -f StyleCopPlus.dll ]; then
echo "Fetching StyleCopPlus from nuget"
nuget install StyleCopPlus.MSBuild -Version 4.7.49.5
cp ./StyleCopPlus.MSBuild.4.7.49.5/tools/StyleCopPlus.dll .
rm -rf StyleCopPlus.MSBuild.4.7.49.5
fi
if [ ! -f StyleCop.dll ]; then if [ ! -f StyleCop.dll ]; then
echo "Fetching StyleCop files from nuget" echo "Fetching StyleCop files from nuget"
nuget install StyleCop.MSBuild -Version 4.7.49.0 nuget install StyleCop.MSBuild -Version 4.7.49.0