Permalink
Browse files

Merge branch 'master' of github.com:hhariri/ReSharperPlugins

  • Loading branch information...
hhariri committed Apr 13, 2012
2 parents 2b4b75f + 1e93d8f commit fa639003a5495334120cd84e7e4041ac2af2adb9
Showing with 221 additions and 146 deletions.
  1. BIN CleanCode/InjectionHappyDetector/resources/InjectionHappyDetector.png
  2. +0 −58 CleanCode/InjectionHappyDetector/src/InjectionHappyDetectorDaemonStage.cs
  3. +1 −1 CleanCode/{InjectionHappyDetector/InjectionHappyDetector.sln → src/CleanCode.sln}
  4. +16 −14 CleanCode/{InjectionHappyDetector/InjectionHappyDetector.csproj → src/CleanCode/CleanCode.csproj}
  5. +20 −8 CleanCode/{InjectionHappyDetector → src/CleanCode}/Properties/AssemblyInfo.cs
  6. BIN CleanCode/src/CleanCode/Settings/CleanCode.png
  7. +29 −17 ...etector/src/InjectionHappyDetectorOptionPage.cs → src/CleanCode/Settings/CleanCodeOptionsPage.cs}
  8. +9 −6 ...appyDetector/src/InjectionHappyDetectorSettings.cs → src/CleanCode/Settings/CleanCodeSettings.cs}
  9. +29 −11 CleanCode/{InjectionHappyDetector/resources → src/CleanCode/Settings}/Stringtable.Designer.cs
  10. +14 −8 CleanCode/{InjectionHappyDetector/resources → src/CleanCode/Settings}/Stringtable.resx
  11. +70 −0 CleanCode/src/CleanCode/TooManyDependencies/TooManyDependenciesDaemonStage.cs
  12. +5 −4 ...emonStageProcess.cs → src/CleanCode/TooManyDependencies/TooManyDependenciesDaemonStageProcess.cs}
  13. +8 −9 ...orElementProcessor.cs → src/CleanCode/TooManyDependencies/TooManyDependenciesElementProcessor.cs}
  14. +11 −4 ...onHappyDetectorWarning.cs → src/CleanCode/TooManyDependencies/TooManyDependenciesHighlighting.cs}
  15. +7 −5 ... → src/CleanCode/TooManyDependencies/TooManyDependenciesInvalidateOnMaximumDependenciesChange.cs}
  16. +2 −1 README.md
@@ -1,58 +0,0 @@
-#region License
-// Copyright (C) 2012 Hadi Hariri and Contributors
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated
-// documentation files (the "Software"), to deal in the Software
-// without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons
-// to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall
-// be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT
-// LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
-// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
-// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
-// OR OTHER DEALINGS IN THE SOFTWARE.
-#endregion
-using System;
-using JetBrains.Application.Settings;
-using JetBrains.ReSharper.Daemon;
-using JetBrains.ReSharper.Psi;
-
-namespace InjectionHappyDetector
-{
- /// <summary>
- /// Daemon stage for comlexity analysis. This class is automatically loaded by ReSharper daemon
- /// because it's marked with the attribute.
- /// </summary>
- [DaemonStage]
- public class InjectionHappyDetectorDaemonStage : IDaemonStage
- {
- /// <summary>
- /// This method provides a <see cref="IDaemonStageProcess"/> instance which is assigned to highlighting a single document
- /// </summary>
- public IDaemonStageProcess CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind kind)
- {
- if (process == null)
- throw new ArgumentNullException("process");
-
- return new InjectionHappyDetectorDaemonStageProcess(process, settings.GetValue((InjectionHappyDetectorSettings s) => s.MaximumParameters));
- }
-
- public ErrorStripeRequest NeedsErrorStripe(IPsiSourceFile sourceFile, IContextBoundSettingsStore settings)
- {
- // We want to add markers to the right-side stripe as well as contribute to document errors
- return ErrorStripeRequest.STRIPE_AND_ERRORS;
- }
- }
-}
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InjectionHappyDetector", "InjectionHappyDetector.csproj", "{4FF42D42-187D-4332-8154-49506B1DB698}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanCode", "CleanCode\CleanCode.csproj", "{4FF42D42-187D-4332-8154-49506B1DB698}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,8 +11,8 @@
<ProjectGuid>{4FF42D42-187D-4332-8154-49506B1DB698}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>InjectionHappyDetector</RootNamespace>
- <AssemblyName>InjectionHappyDetector</AssemblyName>
+ <RootNamespace>CleanCode</RootNamespace>
+ <AssemblyName>CleanCode</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
@@ -41,30 +41,32 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
- <Compile Include="src\InjectionHappyDetectorDaemonStageProcess.cs" />
- <Compile Include="src\InjectionHappyDetectorDaemonStage.cs" />
- <Compile Include="src\InjectionHappyDetectorElementProcessor.cs" />
- <Compile Include="src\InjectionHappyDetectorInvalidateOnMaximumArgumentsChange.cs" />
- <Compile Include="src\InjectionHappyDetectorOptionPage.cs">
- <SubType>Component</SubType>
- </Compile>
- <Compile Include="src\InjectionHappyDetectorSettings.cs" />
+ <Compile Include="TooManyDependencies\TooManyDependenciesDaemonStage.cs" />
+ <Compile Include="TooManyDependencies\TooManyDependenciesDaemonStageProcess.cs" />
+ <Compile Include="TooManyDependencies\TooManyDependenciesElementProcessor.cs" />
+ <Compile Include="TooManyDependencies\TooManyDependenciesInvalidateOnMaximumDependenciesChange.cs" />
+ <Compile Include="TooManyDependencies\TooManyDependenciesHighlighting.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="src\InjectionHappyDetectorWarning.cs" />
- <Compile Include="resources\Stringtable.Designer.cs">
+ <Compile Include="Settings\Stringtable.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Stringtable.resx</DependentUpon>
</Compile>
+ <Compile Include="Settings\CleanCodeOptionsPage.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="Settings\CleanCodeSettings.cs" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="resources\InjectionHappyDetector.png" />
- <EmbeddedResource Include="resources\Stringtable.resx">
+ <EmbeddedResource Include="Settings\Stringtable.resx">
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Stringtable.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Settings\CleanCode.png" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(ReSharperSdkTargets)\Plugin.Targets" />
</Project>
@@ -26,17 +26,20 @@
#endregion
using System.Reflection;
using System.Runtime.InteropServices;
+using CleanCode.TooManyDependencies;
using JetBrains.Application.PluginSupport;
+using JetBrains.ReSharper.Daemon;
+using JetBrains.ReSharper.Daemon.Asp.Highlightings;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly : AssemblyTitle("ReSharper PowerToys: Cyclomatic Complexity")]
+[assembly : AssemblyTitle("ReSharper Clean Code Plugin")]
[assembly : AssemblyDescription("")]
-[assembly : AssemblyCompany("JetBrains s.r.o.")]
-[assembly : AssemblyProduct("ReSharper PowerToys")]
-[assembly : AssemblyCopyright("Copyright \u00A9 2006-2011 JetBrains s.r.o. All rights reserved.")]
+[assembly : AssemblyCompany("Hadi Hariri and Contributors")]
+[assembly : AssemblyProduct("ReSharper Clean Code Plugin")]
+[assembly : AssemblyCopyright("Copyright \u00A9 2012 Hadi Hariri and Contributors")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
@@ -48,7 +51,7 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly : Guid("5f1e5e77-2329-46f6-a95d-58018b440dcb")]
+[assembly : Guid("97927FF9-8C9C-4DC5-A309-29C23F41DA47")]
// Version information for an assembly consists of the following four values:
//
@@ -63,6 +66,15 @@
[assembly : AssemblyVersion("3.0.0.0")]
[assembly : AssemblyFileVersion("3.0.0.0")]
-[assembly : PluginTitle("ReSharper PowerToys: Cyclomatic Complexity")]
-[assembly : PluginVendor("JetBrains s.r.o.")]
-[assembly : PluginDescription("Analyses cyclomatic complexity for a member and issues warnings.")]
+[assembly : PluginTitle("ReSharper Clean Code Plugin")]
+[assembly : PluginVendor("Hadi Hariri and Contributors")]
+
+[assembly:
+ RegisterConfigurableSeverity(
+ TooManyDependenciesHighlighting.SeverityID,
+ null,
+ HighlightingGroupIds.CodeSmell,
+ "Too Many Dependencies",
+ "Too many dependencies passed into constructor",
+ Severity.SUGGESTION,
+ false)]
Binary file not shown.
@@ -27,31 +27,31 @@
#endregion
-using InjectionHappyDetector.resources;
+using System.Windows.Forms;
using JetBrains.Application.Settings;
using JetBrains.DataFlow;
using JetBrains.ReSharper.Features.Environment.Options.Inspections;
using JetBrains.UI.CommonControls.Fonts;
using JetBrains.UI.Options;
using JetBrains.UI.Options.Helpers;
-namespace InjectionHappyDetector
+namespace CleanCode.Settings
{
/// <summary>
/// Implements an options page that holds a set of setting editors stacked in lines from top to bottom.
/// </summary>
- [OptionsPage(PID, "InjectionHappy Detector", "InjectionHappyDetector.resources.InjectionHappyDetector.png",
+ [OptionsPage(PID, "Clean Code", "CleanCode.Settings.CleanCode.png",
ParentId = CodeInspectionPage.PID)]
- public class InjectionHappyDetectorOptionPage : AStackPanelOptionsPage
+ public class CleanCodeOptionsPage : AStackPanelOptionsPage
{
- const string PID = "InjectionHappyDetector";
+ const string PID = "CleanCode";
readonly Lifetime _lifetime;
readonly OptionsSettingsSmartContext _settings;
/// <summary>
- /// Creates new instance of InjectionHappyDetectorOptionPage
+ /// Creates new instance of CleanCodeOptionsPage
/// </summary>
- public InjectionHappyDetectorOptionPage(Lifetime lifetime, FontsManager fontsManager,
+ public CleanCodeOptionsPage(Lifetime lifetime, FontsManager fontsManager,
OptionsSettingsSmartContext settings)
: base(lifetime, fontsManager, PID)
{
@@ -62,28 +62,40 @@ public class InjectionHappyDetectorOptionPage : AStackPanelOptionsPage
void InitControls()
{
- Controls.Spin spin; // This variable may be reused if there's more than one spin on the page
+ Controls.Spin maximumDependencies; // This variable may be reused if there's more than one spin on the page
Controls.HorzStackPanel stack;
// The upper cue banner, stacked in the first line of our page, docked to full width with word wrapping, as needed
- Controls.Add(new Controls.Label(Stringtable.Options_Banner));
+ Controls.Add(new Controls.Label(Stringtable.Options_Header));
+
+ Controls.Add(new Controls.Label(Stringtable.Options_SubHeader));
// Some spacing
Controls.Add(JetBrains.UI.Options.Helpers.Controls.Separator.DefaultHeight);
// A horizontal stack of a text label and a spin-edit
Controls.Add(stack = new Controls.HorzStackPanel());
- stack.Controls.Add(new Controls.Label(Stringtable.Options_MaximumArgumentLabel)); // The first column of the stack
- stack.Controls.Add(spin = new Controls.Spin());
+ stack.Controls.Add(new Controls.Label(Stringtable.Options_LabelMaximumDependenciesCheck));
+ var maximumDependenciesCheckbox = new Controls.CheckBox();
+ stack.Controls.Add(maximumDependenciesCheckbox);
+ stack.Controls.Add(new Controls.Label(Stringtable.Options_LabelTooManyDependencies)); // The first column of the stack
+ stack.Controls.Add(maximumDependencies = new Controls.Spin());
// Set up the spin we've just added
- spin.Maximum = new decimal(new[] {20, 0, 0, 0});
- spin.Minimum = new decimal(new[] {1, 0, 0, 0});
- spin.Value = new decimal(new[] {1, 0, 0, 0});
+ maximumDependencies.Maximum = new decimal(new[] {20, 0, 0, 0});
+ maximumDependencies.Minimum = new decimal(new[] {1, 0, 0, 0});
+ maximumDependencies.Value = new decimal(new[] {1, 0, 0, 0});
+
+ _settings.SetBinding(_lifetime, (CleanCodeSettings s) => s.MaximumDependencies,
+ maximumDependencies.IntegerValue);
+ _settings.SetBinding(_lifetime, (CleanCodeSettings s) => s.MaximumDependenciesEnabled,
+ maximumDependenciesCheckbox.Checked);
+ maximumDependenciesCheckbox.CheckedChanged +=
+ (sender, args) =>
+ { maximumDependencies.Enabled = maximumDependenciesCheckbox.CheckState == CheckState.Checked; };
+
+
- // This binding will take the initial value from InjectionHappyDetectorAnalysisElementProcessor, put it into the edit, and pass back from UI to the control if the OK button is hit
- _settings.SetBinding(_lifetime, (InjectionHappyDetectorSettings s) => s.MaximumParameters,
- spin.IntegerValue);
}
}
}
@@ -1,4 +1,4 @@
-#region License
+#region License
// Copyright (C) 2012 Hadi Hariri and Contributors
//
@@ -30,12 +30,15 @@
using JetBrains.Application.Settings;
using JetBrains.ReSharper.Settings;
-namespace InjectionHappyDetector
+namespace CleanCode.Settings
{
- [SettingsKey(typeof (CodeInspectionSettings), "InjectionHappyDetector")]
- public class InjectionHappyDetectorSettings
+ [SettingsKey(typeof (CodeInspectionSettings), "CleanCode")]
+ public class CleanCodeSettings
{
- [SettingsEntry(3, "MaximumParameters")]
- public readonly int MaximumParameters;
+ [SettingsEntry(3, "MaximumDependencies")]
+ public readonly int MaximumDependencies;
+
+ [SettingsEntry(true, "MaximumDependenciesEnabled")]
+ public readonly bool MaximumDependenciesEnabled;
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit fa63900

Please sign in to comment.