Skip to content

Commit

Permalink
OMG StyleCop
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Nov 9, 2014
1 parent 5dfa7ee commit 8527692
Show file tree
Hide file tree
Showing 96 changed files with 4,863 additions and 1,767 deletions.
6 changes: 6 additions & 0 deletions src/Common.props
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
</PropertyGroup>
</Project>
185 changes: 185 additions & 0 deletions src/Settings.StyleCop
@@ -0,0 +1,185 @@
<StyleCopSettings Version="105">
<GlobalSettings>
<BooleanProperty Name="ViolationsAsErrors">True</BooleanProperty>
</GlobalSettings>
<Parsers>
<Parser ParserId="StyleCop.CSharp.CsParser">
<ParserSettings>
<BooleanProperty Name="AnalyzeGeneratedFiles">True</BooleanProperty>
</ParserSettings>
</Parser>
</Parsers>
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
<Rules>
<Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="PrefixLocalCallsWithThis">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PrefixCallsCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
<Rules>
<Rule Name="FieldNamesMustNotBeginWithUnderscore">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementMustBeginWithLowerCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="InterfaceNamesMustBeginWithI">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstFieldNamesMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FieldNamesMustNotUseHungarianNotation">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FieldNamesMustBeginWithLowerCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="AccessibleFieldsMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="VariableNamesMustNotBePrefixed">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FieldNamesMustNotContainUnderscore">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="StaticReadonlyFieldsMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="FileMustHaveHeader">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustContainWhitespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustShowCopyright">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings>
<BooleanProperty Name="IgnorePrivates">True</BooleanProperty>
<BooleanProperty Name="IncludeFields">False</BooleanProperty>
<BooleanProperty Name="IgnoreInternals">True</BooleanProperty>
</AnalyzerSettings>
</Analyzer>
<Analyzer AnalyzerId="StyleCopPlus.StyleCopPlusRules">
<Rules>
<Rule Name="CodeLineMustNotEndWithWhitespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="CheckWhetherLastCodeLineIsEmpty">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings>
<StringProperty Name="AdvancedNaming_ProtectedInstanceField">_$(aaBb)</StringProperty>
<StringProperty Name="AdvancedNaming_PrivateInstanceField">_$(aaBb)</StringProperty>
<StringProperty Name="AdvancedNaming_ProtectedStaticField">_$(aaBb)</StringProperty>
<StringProperty Name="AdvancedNaming_PrivateStaticField">$(AaBb)</StringProperty>
<StringProperty Name="AdvancedNaming_ProtectedConst">$(AaBb)</StringProperty>
<StringProperty Name="AdvancedNaming_PrivateConst">$(AaBb):$(AA_BB)</StringProperty>
<StringProperty Name="AdvancedNaming_MethodTest">$(AaBb):$(Aa_Bb):$(aa_bb):$(A)$(*)</StringProperty>
<StringProperty Name="SP2001_Mode">Spaces:False</StringProperty>
<StringProperty Name="AdvancedNaming_Namespace">$(*)</StringProperty>
<StringProperty Name="SP2100_Limit">180:4</StringProperty>
<StringProperty Name="AdvancedNaming_Words">3D A B C DB FxCop I ID IDs IRI MSSQL N OK R2RML RDF RML SQL StyleCop URI X</StringProperty>
</AnalyzerSettings>
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.SpacingRules">
<Rules>
<Rule Name="TabsMustNotBeUsed">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
1 change: 1 addition & 0 deletions src/TCode.r2rml4net.sln
Expand Up @@ -16,6 +16,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4EAAEB3C-B182-4E09-BEF1-576977F217BA}"
ProjectSection(SolutionItems) = preProject
after.TCode.r2rml4net.sln.targets = after.TCode.r2rml4net.sln.targets
Common.props = Common.props
Build\Common.targets = Build\Common.targets
..\r2rml.net.nuspec = ..\r2rml.net.nuspec
EndProjectSection
Expand Down
2 changes: 2 additions & 0 deletions src/TCode.r2rml4net.sln.DotSettings
@@ -1,6 +1,8 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Update_0020licence/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Update licence"&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;/Profile&gt;</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderRegionName/@EntryValue">Licence</s:String>
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">Copyright (C) 2012-$CURRENT_YEAR$ Tomasz Pluskiewicz&#xD;
http://r2rml.net/&#xD;
Expand Down
9 changes: 7 additions & 2 deletions src/TCode.r2rml4net/DirectR2RMLMapping.cs
Expand Up @@ -45,7 +45,7 @@
namespace TCode.r2rml4net
{
/// <summary>
/// Provides default mapping by wrapping the <see cref="R2RMLMappingGenerator"/>
/// Provides default mapping by wrapping the <see cref="R2RMLMappingGenerator" />
/// </summary>
public class DirectR2RMLMapping : IR2RML
{
Expand All @@ -61,25 +61,30 @@ public DirectR2RMLMapping(IDatabaseMetadata provider)
}

/// <summary>
/// Creates a default mapping with a base URI set
/// Initializes a new instance of the <see cref="DirectR2RMLMapping"/> class.
/// </summary>
/// <param name="provider">The provider.</param>
/// <param name="baseMappingUri">The base mapping URI.</param>
public DirectR2RMLMapping(IDatabaseMetadata provider, Uri baseMappingUri)
{
_generator = new R2RMLMappingGenerator(provider, new FluentR2RML(baseMappingUri));
}

/// <inheritdoc/>
public ISqlVersionValidator SqlVersionValidator
{
get { return GeneratedMappings.SqlVersionValidator; }
set { GeneratedMappings.SqlVersionValidator = value; }
}

/// <inheritdoc/>
public ISqlQueryBuilder SqlQueryBuilder
{
get { return GeneratedMappings.SqlQueryBuilder; }
set { GeneratedMappings.SqlQueryBuilder = value; }
}

/// <inheritdoc/>
public IEnumerable<ITriplesMap> TriplesMaps
{
get { return GeneratedMappings.TriplesMaps; }
Expand Down
7 changes: 5 additions & 2 deletions src/TCode.r2rml4net/Exceptions/InvalidMapException.cs
Expand Up @@ -46,16 +46,19 @@ namespace TCode.r2rml4net.Exceptions
public class InvalidMapException : Exception
{
/// <summary>
/// Creates an instance of <see cref="InvalidMapException"/> with a message
/// Initializes a new instance of the <see cref="InvalidMapException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="triplesMap">The triples map.</param>
public InvalidMapException(string message, IMapBase triplesMap)
: base(string.Format("Map {0} is invalid. {1}", triplesMap.Node, message))
{
}

/// <summary>
/// Creates an instance of <see cref="InvalidMapException"/> with a message
/// Initializes a new instance of the <see cref="InvalidMapException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public InvalidMapException(string message)
: base(message)
{
Expand Down
3 changes: 2 additions & 1 deletion src/TCode.r2rml4net/Exceptions/InvalidTemplateException.cs
Expand Up @@ -46,8 +46,9 @@ namespace TCode.r2rml4net.Exceptions
public class InvalidTemplateException : InvalidTermException
{
/// <summary>
/// Creates a new instance of <see cref="InvalidTemplateException"/> for a <paramref name="termMap"/>
/// Initializes a new instance of the <see cref="InvalidTemplateException"/> class.
/// </summary>
/// <param name="termMap">The term map.</param>
public InvalidTemplateException(ITermMap termMap)
: base(termMap, "Template is missing")
{
Expand Down
14 changes: 7 additions & 7 deletions src/TCode.r2rml4net/Exceptions/InvalidTermException.cs
Expand Up @@ -46,19 +46,19 @@ namespace TCode.r2rml4net.Exceptions
public class InvalidTermException : Exception
{
/// <summary>
/// The <a href="http://www.w3.org/TR/r2rml/#term-map">term map</a>,
/// which cannot be used to <a href="http://www.w3.org/TR/r2rml/#generated-rdf-term">generate an RDF term</a>
/// </summary>
public ITermMap TermMap { get; private set; }

/// <summary>
/// Creates a new instance of <see cref="InvalidTermException"/> for a <paramref name="termMap"/>
/// Initializes a new instance of <see cref="InvalidTermException"/> for a <paramref name="termMap"/>
/// with a given <paramref name="reason"/> why it occured
/// </summary>
public InvalidTermException(ITermMap termMap, string reason)
: base(string.Format("Cannot generate RDF term for '{0}'. {1}", termMap.Node, reason))
{
TermMap = termMap;
}

/// <summary>
/// Gets the <a href="http://www.w3.org/TR/r2rml/#term-map">term map</a>,
/// which cannot be used to <a href="http://www.w3.org/TR/r2rml/#generated-rdf-term">generate an RDF term</a>
/// </summary>
public ITermMap TermMap { get; private set; }
}
}
5 changes: 3 additions & 2 deletions src/TCode.r2rml4net/Extensions/GraphExtensions.cs
Expand Up @@ -180,8 +180,9 @@ public static string GetLanguageTag([AllowNull] this INode node, [AllowNull] Fun
private static InvalidMapException MultipleResultsException(IEnumerable<INode> nodes)
{
return new InvalidMapException(
string.Format("Expected at most on values for predicate but got:\r\n{0}",
string.Join("\r\n", nodes.Select(node => node.ToString()))));
string.Format(
"Expected at most on values for predicate but got:\r\n{0}",
string.Join("\r\n", nodes.Select(node => node.ToString()))));
}
}
}
7 changes: 2 additions & 5 deletions src/TCode.r2rml4net/Extensions/UriExtensions.cs
Expand Up @@ -53,23 +53,20 @@ public static class UriExtensions
public static void LeaveDotsAndSlashesEscaped(this Uri uri)
{
const int unEscapeDotsAndSlashes = 0x2000000;
if (uri == null)
{
throw new ArgumentNullException("uri");
}

FieldInfo fieldInfo = uri.GetType().GetField("m_Syntax", BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo == null)
{
throw new MissingFieldException("'m_Syntax' field not found");
}

object uriParser = fieldInfo.GetValue(uri);

fieldInfo = typeof(UriParser).GetField("m_Flags", BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo == null)
{
throw new MissingFieldException("'m_Flags' field not found");
}

object uriSyntaxFlags = fieldInfo.GetValue(uriParser);

// Clear the flag that we don't want
Expand Down

0 comments on commit 8527692

Please sign in to comment.