Rules

CheckId Severity Description ReSharper
CSC515503 CriticalError Do not deploy Taxonomy fields using List Definitions. +
CSC515201 CriticalWarning Avoid list content types. +
CSC515403 CriticalWarning Avoid system list names for the custom list instances. +
CSC510202 CriticalWarning ConfigurationManager class should not be used. +
CSC515204 CriticalWarning Consider Overwrite="TRUE" for content types. +
CSC515104 CriticalWarning Consider Overwrite="TRUE" for fields. +
CSC510219 CriticalWarning Do not delete user profile.
CSC510212 CriticalWarning Do not use DirectorySearcher class to query ActiveDirectory. +
CSC510213 CriticalWarning Do not use unsafe casts on SPListItem. +
CSC515504 CriticalWarning Ensure Folder ContentTypeRef in List Definition. +
CSC510238 CriticalWarning Missing SPUrlZone parameter in SPSite constructor. +
CSC515203 Error Deploy Content Types correctly. +
CSC515103 Error Deploy fields correctly. +
CSC510243 Error Do not change SPPersistedObject in the content web application. +
CSC510246 Error Do not dispose PersonalSite or PersonalWeb.
CSC515105 Error Field ID attribute must be upper-case. +
CSC510209 Error Inappropriate SPListCollection usage. +
CSC515402 Error List instance URL has to be unique. +
CSC510247 Error Multiple SPView instances could not be updated at once. +
CSC510236 Error Do not suppress general exceptions. +
CSC517305 Error Set AutoGenerateColumns=false for SPGridView in the master page. +
CSC516905 Error Set AutoGenerateColumns=false for SPGridView in the page. +
CSC516806 Error Set AutoGenerateColumns=false for SPGridView in the user control. +
CSC510401 Error Unresolved token $SharePoint.Project.AssemblyFullName$.
CSC510237 Information Assembly does not contains ULS logging.
CSC510235 Information Avoid SPObject.Name == <string> comparison. +
CSC510229 Information Avoid using ClientScriptManager/ScriptManager.
CSC510206 Information Consider Secure Store Service instead of direct connection. +
CSC515202 Information Do not define multiple content type groups in one element file. +
CSC515102 Information Do not define multiple field groups in one element file. +
CSC510203 Information ListFieldIterator is used.
CSC515107 Information Prevent SharePoint field from deletion. +
CSC515505 Information Prevent SharePoint list from deletion. +
CSC512106 Information Recommended to set "Always force install" feature flag to True.
CSC516803 Information RenderingTemplate is used.
CSC510208 Information SPMonitoredScope should be used for web parts, pages and controls. +
CSC510201 Information Thread.Sleep() method should not be used. +
CSC516401 Information Web part description might be improved. +
CSC516402 Information Web part group property should not be 'Custom'. +
CSC510231 Information Workflow does not start if list modified from timer job.
CSC516903 Warning Avoid using jQuery(document).ready in page. +
CSC510204 Warning Avoid enumerating all user profiles. +
CSC515303 Warning Avoid InfoPath forms.
CSC510228 Warning Avoid unsafe url concatenations. +
CSC518901 Warning Avoid using $ as jQuery reference in .js file. +
CSC516801 Warning Avoid using $ as jQuery reference in ASCX user control. +
CSC516901 Warning Avoid using $ as jQuery reference in ASPX page. +
CSC517301 Warning Avoid using $ as jQuery reference in master page. +
CSC516403 Warning Avoid using $ as jQuery reference in web part.
CSC510242 Warning Avoid using $ as jQuery reference. +
CSC510211 Warning Avoid using AjaxControlToolkit.
CSC518902 Warning Avoid using jQuery(document).ready in .js file. +
CSC516804 Warning Avoid using jQuery(document).ready in ASCX user control. +
CSC510223 Warning Avoid using jQuery(document).ready in C# code. +
CSC517303 Warning Avoid using jQuery(document).ready in master page. +
CSC516404 Warning Avoid using jQuery(document).ready in web part.
CSC516805 Warning Avoid using of UpdatePanel in ASCX user control.
CSC510248 Warning Avoid using of UpdatePanel in code.
CSC517304 Warning Avoid using of UpdatePanel in master page.
CSC516904 Warning Avoid using of UpdatePanel in page.
CSC510222 Warning Avoid using SPContext.Current outside of web request context. +
CSC510234 Warning Avoid using static SP-Objects In Fields. +
CSC515501 Warning Consider create hidden list templates. +
CSC515502 Warning Declare empty Fields element. +
CSC515101 Warning Deploy Taxonomy fields correctly. +
CSC510244 Warning Do not impersonate with RunWithElevatedPrivileges when HTTPContext is null. +
CSC510239 Warning Do not use custom logging tools +
CSC510251 Warning Do not use EntityEditor.Entities collection. +
CSC510225 Warning Do not use hardcoded urls, pathes, emails and account names in code. +
CSC512105 Warning Do not use hardcoded urls, pathes, emails and account names in xml.
CSC510245 Warning Do not use Microsoft.Office.Server.Diagnostics.PortalLog. +
CSC510226 Warning Do not use SPListItem.File. +
CSC510240 Warning Do not use SPWeb.Properties collection. +
CSC510249 Warning Do not use SPWebPartManager when HTTPContext is null. +
CSC512102 Warning Feature should have not empty ImageUrl attribute.
CSC510227 Warning Inappropriate taxonomy collection usage. +
CSC510224 Warning Multiple WHERE clauses is not supported for Camlex.Query.
CSC510241 Warning Not logged exception found. +
CSC510250 Warning Put SPFile.Exists into try ... catch block. +
CSC510252 Warning Send an e-mail from a WCF service when SPContext is not available. +
CSC515106 Warning ShowField attribute value NameWithPicture is not recommended. +
CSC510232 Warning Some recommended practices regarding GetPublishingPages method utilization. +
CSC517302 Warning SPDataSource scope is not defined in master page. +
CSC516902 Warning SPDataSource scope is not defined in page. +
CSC516802 Warning SPDataSource scope is not defined in user control. +
CSC510218 Warning SPDataSource scope is not defined. +
CSC512101 Warning SPFeature should not be activated via code. +
CSC510210 Warning SPQuery scope is not defined. +
CSC510205 Warning SPView scope is not defined. +
CSC510207 Warning Using SPWeb.GetFile method is preferable.|

Metrics

  1. Control templates count
  2. External dll count
  3. Layouts pages count
  4. Masterpage files count
  5. Xsl/Xslt files count
  6. BreakInheritance/ResetRoleInheritance call count

Experimental metrics

  1. SPMonitoredScope usage count

Inventories

  1. Property bag stores custom value
  2. HttpRequest collections monitoring
  3. Constants
  4. Custom master pages
  5. Method strings
  6. Delegate controls

Experimental inventories

  1. Search properties
  2. User profile properties

Experimental items are located in the different project and could be shipped on demand.
The full table of implemented items is located here

Using predefined rule sets.

To get more accurate result of analyse you can select one of the OOTB rule set. Please read more about rule set list here.

From Aprile 2014 release we provided our own rule set - Community.spruleset file. It is focused on the C# developers and architectors. You can modify it anyhow or use it as example to create new one. Just to remember, any ruleset file contains ONLY prohibited items (categories by name or rules by CheckId). See installation details on the download page to get it work. To select it in Visual Studio do follow: click.png Rule_Set_Selection.png

ReSharper plugin

Using ReSharper you have an online validation of code, markup, xml and javascript. Once installed the SPCAFContrib plugin pay your attention on the problems in SharePoint API usage, potential performance issues, invalid xml tags and others. Code inspection is performed automatically in design time for all files opened in the editor. Depends on issue severity level the problem text is highlighted in different ways and corresponded color marks are added to the marker bar. Mostly each of highlightings has a quick fix action (look as a bulb). And you can apply this fix on the current file, current folder or project or whole solution.

ReplacejQuery.gif

Bulk action
bulk.gif

Like SPCAF ReSharper can analyse whole solution and expose list of incidents in the separate windows: "Inspection results" and "Solution wide error analyse".

inspect_results.gif

Unfortunatelly currently it is not supported for XML and JS files. You need to open its in the Visual Studio editor and check marker bar.


How to change rule severity in the ReSharper?
1 approach:
  1. Open ReSharper | Option dialog and select Code Inspection | Inspection Severity
  2. Click on the SPCAF Contrib title
  3. Click on the colored box with curent severity level.

2 approach:
severity.gif

How can I read more about highlighting?
Open context menu, select Options for "name of issue" and select "Why is SPCAF Contrib suggestion this?". The help page will be opened immediatelly in the browser.
HelpLink.jpg

You can read more about ReSharper code inspection here.

How can I do something more with ReSharper?
Read this article to know about live templates.

Where I can find the quick access key map in for ReSharper?
Check out this guide (PDF).

How can I enable/disable ReSharper code analysis for specific files?
  • Ctrl-8 for the current file, for the current session.
  • Ctrl-Alt-8 for disabling Resharper code analysis.

Suggested new rules and metrics

Please consider starting a new issue here to let us know about that.

Development

Few things about CheckId generation.

List of excluded libraries

SPCAF/SPCop
Some time we need to eliminate 3-rd party assembly from analyse. Currently there are follow exceptions:
  • Aspose.*.dll
  • Telerik.*.dll
  • System.*.dll
  • Microsoft.*.dll
  • DocumentFormat.OpenXml.dll
  • ClosedXml.dll
  • NVelocity.dll
  • Camlex.NET.dll
  • AjaxControlToolkit.dll
If you want to add your own assembly to list above please be free to post it name to us.

ReSharper
You can configure lists of ignored files using regular expression or wildcards in the ReSharper | Options dialog.
ROptions.png

Last edited Dec 31, 2014 at 11:32 AM by dvd73, version 170

Comments

No comments yet.