Skip to content

Instantly share code, notes, and snippets.

@jeffward01
Created June 3, 2020 08:32
Show Gist options
  • Save jeffward01/dddda68dd066480d4f0f4ce61f9c93ac to your computer and use it in GitHub Desktop.
Save jeffward01/dddda68dd066480d4f0f4ce61f9c93ac to your computer and use it in GitHub Desktop.
This file is to customise the rule behaviour (NOT to enable/disable rules!). For example, this example changes the usingDirectivesPlacement rule to enforce that using statements should be outside the namespace (i.e. at the top of the file). This is an alternative to simply disabling the rule. Link: https://medium.com/@michaelparkerdev/linting-c-…
{
$schema: "http://json-schema.org/draft-04/schema#",
id: "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
title: "StyleCop Analyzers Configuration",
description: "Configuration file for StyleCop Analyzers",
type: "object",
properties: {
settings: {
type: "object",
description: "The top-level object containing configuration properties for built-in rules.",
additionalProperties: false,
properties: {
indentation: {
type: "object",
description: "Indentation configuration",
additionalProperties: false,
properties: {
indentationSize: {
description: "Specifies the indentation size.",
type: "integer",
minimum: 0,
default: 4
},
tabSize: {
description: "Specifies the tab width.",
type: "integer",
minimum: 0,
default: 4
},
useTabs: {
description: "Specifies whether indentation should use hard tabs instead of spaces.",
type: "boolean",
default: false
}
}
},
spacingRules: {
type: "object",
description: "Configuration for spacing rules (SA1000-)",
additionalProperties: false,
properties: { }
},
readabilityRules: {
type: "object",
description: "Configuration for readability rules (SA1100-)",
additionalProperties: false,
properties: {
allowBuiltInTypeAliases: {
type: "boolean",
description: "When true, diagnostics will not be reported for using aliases of built-in types.",
default: false
}
}
},
orderingRules: {
type: "object",
description: "Configuration for ordering rules (SA1200-)",
additionalProperties: false,
properties: {
elementOrder: {
type: "array",
description: "Specifies the traits used for ordering elements within a document, along with their precedence.",
default: [
"kind",
"accessibility",
"constant",
"static",
"readonly"
],
items: {
type: "string",
description: "",
enum: [
"accessibility",
"kind",
"constant",
"static",
"readonly"
]
},
uniqueItems: true
},
systemUsingDirectivesFirst: {
type: "boolean",
description: "When true, System using directives should be placed before other using directives.",
default: true
},
usingDirectivesPlacement: {
type: "string",
description: "Specifies the desired placement of using directives. insideNamespace: Place using directives inside the namespace definition outsideNamespace: Place using directives outside the namespace definition preserve: Allow using directives inside or outside the namespace definition",
enum: [
"insideNamespace",
"outsideNamespace",
"preserve"
],
default: "insideNamespace"
},
blankLinesBetweenUsingGroups: {
type: "string",
description: "Specifies if using groups should be separated by a blank line. allow: A blank line is allowed, but not required require: A blank line is required omit: A blank line is not allowed",
enum: [
"allow",
"require",
"omit"
],
default: "allow"
}
}
},
namingRules: {
type: "object",
description: "Configuration for naming rules (SA1300-)",
additionalProperties: false,
properties: {
allowCommonHungarianPrefixes: {
type: "boolean",
description: "Determines whether common Hungarian notation prefixes should be allowed.",
default: true
},
allowedHungarianPrefixes: {
type: "array",
description: "Allowed Hungarian notation prefixes.",
default: [ ],
items: {
type: "string",
pattern: "^[a-z]{1,2}$",
uniqueItems: true
}
},
allowedNamespaceComponents: {
type: "array",
description: "Allowed namespace components, such as ones beginning with a lowercase letter.",
default: [ ],
items: {
type: "string",
uniqueItems: true
}
},
includeInferredTupleElementNames: {
type: "boolean",
description: "Specifies whether inferred tuple element names will be analyzed as well.",
default: false
},
tupleElementNameCasing: {
type: "string",
description: "Specifies the casing convention used for tuple element names.",
enum: [
"camelCase",
"PascalCase"
],
default: "PascalCase"
}
}
},
maintainabilityRules: {
type: "object",
description: "Configuration for ordering rules (SA1400-)",
additionalProperties: false,
properties: {
topLevelTypes: {
type: "array",
description: "The set of type kinds which should be placed in separate files according to the type name.",
default: [
"class"
],
items: {
type: "string",
enum: [
"class",
"interface",
"struct",
"delegate",
"enum"
]
},
uniqueItems: true
}
}
},
layoutRules: {
type: "object",
description: "Configuration for layout rules (SA1500-)",
additionalProperties: false,
properties: {
newlineAtEndOfFile: {
type: "string",
description: "Specifies the handling for newline characters which appear at the end of a file allow: Files are allowed to end with a single newline character, but it is not required require: Files are required to end with a single newline character omit: Files may not end with a newline character",
enum: [
"allow",
"require",
"omit"
],
default: "allow"
},
allowConsecutiveUsings: {
type: "boolean",
description: "Specifies if SA1519 will allow consecutive using statements without braces",
default: true
}
}
},
documentationRules: {
type: "object",
description: "Configuration for documentation rules (SA1600-)",
additionalProperties: false,
properties: {
documentExposedElements: {
type: "boolean",
description: "Specifies whether exposed elements need to be documented. When true, all publicly-exposed types and members require documentation.",
default: true
},
documentInternalElements: {
type: "boolean",
description: "Specifies whether internal elements need to be documented. When true, all internally-exposed types and members require documentation.",
default: true
},
documentPrivateElements: {
type: "boolean",
description: "Specifies whether private elements need to be documented. When true, all types and members except for declared private fields require documentation.",
default: false
},
documentInterfaces: {
type: "boolean",
description: "Specifies whether interface members need to be documented. When true, all interface members require documentation, regardless of accessibility.",
default: true
},
documentPrivateFields: {
type: "boolean",
description: "Specifies whether private fields need to be documented. When true, all fields require documentation, regardless of accessibility.",
default: false
},
companyName: {
type: "string",
description: "The name of the company which appears in file headers.",
default: "PlaceholderCompany"
},
copyrightText: {
type: "string",
description: "The copyright text which should appear in file headers.",
default: "Copyright (c) {companyName}. All rights reserved."
},
variables: {
type: "object",
description: "Replacement variables which may be used in the 'copyrightText' value.",
patternProperties: {
^[a-zA-Z0-9]+$: {
type: "string"
}
},
additionalProperties: false
},
xmlHeader: {
type: "boolean",
description: "Determines whether the file header should be wrapped in the StyleCop-standard XML structure.",
default: true
},
headerDecoration: {
type: "string",
description: "The text used as decoration for the copyright header comment.",
default: null
},
fileNamingConvention: {
type: "string",
description: "Specifies the preferred naming convention for files. The default value "stylecop" uses the naming convention defined by StyleCop Classic, while "metadata" uses a file naming convention that matches the metadata names of types.",
default: "stylecop",
enum: [
"stylecop",
"metadata"
]
},
documentationCulture: {
type: "string",
description: "The culture that should be used for documentation comments.",
default: "en-US"
},
excludeFromPunctuationCheck: {
type: "array",
description: "Specifies the top-level tags within XML documentation that will be excluded from punctuation analysis.",
default: [
"seealso"
]
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment