public override void Check(ICheckerContext context) { foreach (var mediaFile in context.Project.ProjectItems.OfType<MediaFile>()) { CheckTemplate(context, mediaFile); } }
public override void Check(ICheckerContext context) { foreach (var item in context.Project.Items) { CheckTemplate(context, item); } }
public override void Check(ICheckerContext context) { foreach (var template in context.Project.Templates) { CheckTemplate(context, template); } }
public override void Check(ICheckerContext context) { var rules = RuleService.ParseRules("check-project:conventions").ToArray(); context.ConventionCount += rules.Length; CheckProject(context, rules); CheckProjectItems(context, rules); }
public override void Check(ICheckerContext context) { foreach (var field in context.Project.Items.SelectMany(i => i.Fields)) { if (field.Value.IndexOf("Lorem Ipsum", StringComparison.InvariantCultureIgnoreCase) >= 0) { context.Trace.TraceWarning(Msg.C1008, "Lorem Ipsum text", TraceHelper.GetTextNode(field.ValueProperty, field.FieldNameProperty, field), $"The field \"{field.FieldName}\" contains the test data text: \"Lorem Ipsum...\". Replace or remove the text data."); } } }
public override void Check(ICheckerContext context) { foreach (var item in context.Project.Items) { var count = item.GetChildren().Count(); if (count > 100) { context.Trace.TraceWarning(Msg.C1009, "Item has many children", $"The item has {count} children. Items with more than 100 children decrease performance. Change the structure of the tree to reduce the number of children."); } } }
public override void Check(ICheckerContext context) { foreach (var template in context.Project.Templates) { foreach (var templateField in template.Fields) { if (templateField.Source.IndexOf('/') >= 0) { context.Trace.TraceWarning(Msg.C1026, "Use IDs instead of paths in template fields", TraceHelper.GetTextNode(templateField.SourceProperty, templateField), $"The template field Source field contains the path \"{templateField.Source}\". It is recommended to use IDs instead."); } } } }
public override void Check(ICheckerContext context) { foreach (var item in context.Project.Items) { var archiveDate = item[Constants.Fields.ArchiveDate].FromIsoToDateTime(); var reminderDate = item[Constants.Fields.ReminderDate].FromIsoToDateTime(); if (reminderDate != DateTime.MinValue && archiveDate != DateTime.MinValue && reminderDate > archiveDate) { context.Trace.TraceWarning(Msg.C1002, "Reminder/Archive dates", TraceHelper.GetTextNode(item.Fields[Constants.Fields.ArchiveDate], item.Fields[Constants.Fields.ReminderDate], item), "The Reminder date is after the Archive date. Change either the Reminder date or the Archive date."); } } }
public override void Check(ICheckerContext context) { var queryService = context.CompositionService.Resolve<IQueryService>(); foreach (var template in context.Project.Templates) { var references = queryService.FindUsages(context.Project, template.QualifiedName); if (!references.Any()) { context.Trace.TraceWarning(Msg.C1025, "Unused template", TraceHelper.GetTextNode(template), $"The template \"{template.ItemName}\" is not used by any items and can be deleted."); } } }
public override void Check(ICheckerContext context) { foreach (var item in context.Project.Items) { foreach (var language in item.GetLanguages()) { var count = item.GetVersions(language).Count(); if (count >= 10) { context.Trace.TraceWarning(Msg.C1010, "Item has many version", $"The item has {count} versions in the {language} language. Items with more than 10 version decrease performance. Remove some of the older versions."); } } } }
public override void Check(ICheckerContext context) { foreach (var projectItem in context.Project.ProjectItems) { foreach (var reference in projectItem.References) { if (!reference.IsValid) { var details = reference.SourceProperty.GetValue(); context.Trace.TraceWarning(Msg.C1000, "Reference not found", projectItem.Snapshots.First().SourceFile.AbsoluteFileName, reference.SourceProperty?.SourceTextNode?.TextSpan ?? TextSpan.Empty, details); } } } }
public override void Check(ICheckerContext context) { foreach (var template in context.Project.Templates) { foreach (var field in template.Fields) { var type = field.Type; string newType = null; switch (type.ToLowerInvariant()) { case "text": newType = "Single-Line Text"; break; case "html": newType = "Rich Text"; break; case "link": newType = "General Link"; break; case "lookup": newType = "Droplink"; break; case "memo": newType = "Multi-Line Text"; break; case "reference": newType = "Droptree"; break; case "server file": newType = "Single-Line Text"; break; case "tree": newType = "Droptree"; break; case "treelist": newType = "TreelistEx"; break; case "valuelookup": newType = "Droplist"; break; } if (!string.IsNullOrEmpty(newType)) { context.Trace.TraceWarning(Msg.C1022, "Deprecated template field type", TraceHelper.GetTextNode(field.TypeProperty, field), $"The template field type \"{type}\" is deprecated. Use the \"{newType}\" field type."); } } } }
public override void Check(ICheckerContext context) { foreach (var field in context.Project.Items.SelectMany(i => i.Fields).Where(f => string.Equals(f.TemplateField.Type, "Number", StringComparison.OrdinalIgnoreCase))) { if (string.IsNullOrEmpty(field.Value)) { continue; } int value; if (!int.TryParse(field.Value, out value)) { context.Trace.TraceWarning(Msg.C1057, "Number", TraceHelper.GetTextNode(field.ValueProperty, field.FieldNameProperty, field), $"The field \"{field.FieldName}\" has a type of 'Number', but the value is not a valid number. Replace or remove the value."); } } }
public override void Check(ICheckerContext context) { var parents = new HashSet<Item>(); foreach (var item in context.Project.Items) { var parent = item.GetParent(); if (parent == null) { continue; } if (parents.Contains(parent)) { continue; } parents.Add(parent); var children = parent.GetChildren().ToArray(); for (var i0 = 0; i0 < children.Length - 2; i0++) { var child0 = children[i0]; for (var i1 = i0 + 1; i1 < children.Length - 1; i1++) { var child1 = children[i1]; var languages = child0.GetLanguages().Intersect(child1.GetLanguages()); foreach (var language in languages) { var displayNames0 = child0.Fields.Where(f => string.Equals(f.FieldName, "__Display Name", StringComparison.OrdinalIgnoreCase) && string.Equals(f.Language, language, StringComparison.OrdinalIgnoreCase)).Select(f => f.Value); var displayNames1 = child1.Fields.Where(f => string.Equals(f.FieldName, "__Display Name", StringComparison.OrdinalIgnoreCase) && string.Equals(f.Language, language, StringComparison.OrdinalIgnoreCase)).Select(f => f.Value); var same = displayNames0.Intersect(displayNames1); if (same.Any()) { context.Trace.TraceError(Msg.C1006, "Items with same display name on same level", TraceHelper.GetTextNode(child0, child1), $"Two or more items have the same display name \"{displayNames0.First()}\" on the same level. Change the display name of one or more of the items."); } } } } } }
public override void Check(ICheckerContext context) { foreach (var item in context.Project.Items) { if (item.Publishing.NeverPublish) { continue; } var validFrom = item.Publishing.ValidFrom; var validTo = item.Publishing.ValidTo; if (validFrom != DateTime.MinValue && validTo != DateTime.MinValue && validFrom > validTo) { context.Trace.TraceWarning(Msg.C1021, "Valid From/Valid To dates", TraceHelper.GetTextNode(item.Fields[Constants.Fields.ValidFrom], item.Fields[Constants.Fields.ValidTo], item), "The Valid From date is after the Valid To date. Change either the Valid From date or the Valid To date."); } } }
public override void Check(ICheckerContext context) { foreach (var item in context.Project.Items) { if (item.Publishing.NeverPublish) { continue; } var publishDate = item.Publishing.PublishDate; var unpublishDate = item.Publishing.PublishDate; if (publishDate != DateTime.MinValue && unpublishDate != DateTime.MinValue && publishDate > unpublishDate) { context.Trace.TraceWarning(Msg.C1011, "Publish/Unpublish dates", TraceHelper.GetTextNode(item.Fields[Constants.Fields.PublishDate], item.Fields[Constants.Fields.UnpublishDate], item), "The Publish date is after the Unpublish date. Change either the Publish date or the Unpublish date."); } } }
public override void Check(ICheckerContext context) { foreach (var item in context.Project.Items) { foreach (var field in item.Fields) { var templateField = field.TemplateField; if (templateField == TemplateField.Empty) { continue; } if (templateField.Uri.Guid != field.FieldId) { context.Trace.TraceWarning(Msg.C1024, "Field ID and Template Field ID differs", TraceHelper.GetTextNode(field.FieldIdProperty, field), $"FieldId: {field.FieldId.Format()}, TemplateFieldId: {templateField.Uri.Guid.Format()}"); } } } }
public override void Check(ICheckerContext context) { var items = context.Project.ProjectItems.Where(i => !(i is DatabaseProjectItem) || !((DatabaseProjectItem)i).IsImport).ToArray(); for (var i = 0; i < items.Length; i++) { var projectItem1 = items[i]; var item1 = projectItem1 as DatabaseProjectItem; for (var j = i + 1; j < items.Length; j++) { var projectItem2 = items[j]; var item2 = items[j] as DatabaseProjectItem; if (projectItem1.Uri.Guid != projectItem2.Uri.Guid) { continue; } if (item1 != null && item2 != null && !string.Equals(item1.DatabaseName, item2.DatabaseName, StringComparison.OrdinalIgnoreCase)) { continue; } // todo: not good if (item1 is Item && item2 is Template) { continue; } if (item1 is Template && item2 is Item) { continue; } context.Trace.TraceError(Msg.C1001, Texts.Unique_ID_clash, projectItem1.Snapshots.First().SourceFile, projectItem2.Snapshots.First().SourceFile.AbsoluteFileName); context.IsDeployable = false; } } }
public override void Check(ICheckerContext context) { foreach (var template in context.Project.Templates) { var fields = template.GetAllFields().ToArray(); for (var i0 = 0; i0 < fields.Length - 2; i0++) { var field0 = fields[i0]; for (var i1 = i0 + 1; i1 < fields.Length - 1; i1++) { var field1 = fields[i1]; if (string.Equals(field0.FieldName, field1.FieldName, StringComparison.OrdinalIgnoreCase)) { context.Trace.TraceWarning(Msg.C1023, "Duplicate template field name", TraceHelper.GetTextNode(field0.FieldNameProperty, field1.FieldNameProperty, field0, field1), $"The template contains two or more field with the same name \"{field0.FieldName}\". Even if these fields are located in different sections, it is still not recommended as the name is ambiguous. Rename one or more of the fields."); } } } } }
public override void Check(ICheckerContext context) { var parents = new HashSet<Item>(); foreach (var item in context.Project.Items) { var parent = item.GetParent(); if (parent == null) { continue; } if (parents.Contains(parent)) { continue; } parents.Add(parent); var children = parent.GetChildren().ToArray(); for (var i0 = 0; i0 < children.Length - 2; i0++) { var child0 = children[i0]; for (var i1 = i0 + 1; i1 < children.Length - 1; i1++) { var child1 = children[i1]; if (string.Equals(child0.ItemName, child1.ItemName, StringComparison.OrdinalIgnoreCase)) { context.Trace.TraceError(Msg.C1007, "Items with same name on same level", TraceHelper.GetTextNode(child0.ItemNameProperty, child1.ItemNameProperty, child0, child1), $"Two or more items have the same name \"{child0.ItemName}\" on the same level. Change the name of one or more of the items."); } } } } }
public IEnumerable <IDiagnostic> RenderingNameAndFileNameShouldMatch([NotNull] ICheckerContext context) { return(from rendering in context.Project.ProjectItems.OfType <Rendering>() where rendering.ItemName != PathHelper.GetFileNameWithoutExtensions(rendering.FilePath) select Warning(context, Msg.C1106, "Rendering item name should match file name", rendering.Snapshot.SourceFile, "To fix, rename the rendering file or rename the rendering item")); }
protected virtual void EnableCheckers([NotNull] ICheckerContext context, [NotNull, ItemNotNull] IEnumerable <CheckerInfo> checkers, [NotNull] string configurationKey) { foreach (var pair in Configuration.GetSubKeys(configurationKey)) { if (pair.Key == BasedOn) { var baseName = Constants.Configuration.ProjectRoleCheckers + ":" + Configuration.GetString(configurationKey + ":" + pair.Key); EnableCheckers(context, checkers, baseName); } } foreach (var pair in Configuration.GetSubKeys(configurationKey)) { var key = pair.Key; if (key == BasedOn) { continue; } var severity = CheckerSeverity.Default; switch (Configuration.GetString(configurationKey + ":" + key).ToLowerInvariant()) { case "disabled": severity = CheckerSeverity.Disabled; break; case "enabled": severity = CheckerSeverity.Default; break; case "information": severity = CheckerSeverity.Information; break; case "warning": severity = CheckerSeverity.Warning; break; case "error": severity = CheckerSeverity.Error; break; } if (key == "*") { foreach (var c in checkers) { c.Severity = severity; } foreach (var c in context.Checkers) { context.Checkers[c.Key] = severity; } continue; } context.Checkers[key] = severity; foreach (var checker in checkers) { if (checker.Name == key || checker.Category == key) { checker.Severity = severity; } } } }
public IEnumerable <IDiagnostic> DataSourceTemplatesMustInheritFromDataTemplates([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where IsDataSourceTemplate(template) from baseTemplate in template.GetBaseTemplates() where baseTemplate.ItemName != "Standard template" && !IsDataTemplate(baseTemplate) select Error(context, Msg.C1071, $"Data Source templates must not inherit from {baseTemplate.ItemName} as it is not a Data Template. To fix, either remove the inheritance or make the base template a Data Template", TraceHelper.GetTextNode(template))); }
public IEnumerable <IDiagnostic> CheckboxMustBeTrueOrFalse([NotNull] ICheckerContext context) { return(from field in context.Project.Items.SelectMany(i => i.Fields).Where(f => string.Equals(f.TemplateField.Type, "Checkbox", StringComparison.OrdinalIgnoreCase)) where !string.Equals(field.Value, "true", StringComparison.OrdinalIgnoreCase) && !string.Equals(field.Value, "false", StringComparison.OrdinalIgnoreCase) select Error(context, Msg.C1066, Texts.Checkbox_field_value_must_be__true__or__false__, TraceHelper.GetTextNode(field.ValueProperty, field.FieldNameProperty, field), details : $"The field \"{field.FieldName}\" has a type of 'Checkbox', but the value is not a valid boolean. Set the value to 'true' or 'false'.")); }
public IEnumerable <IDiagnostic> TemplateShortHelpShouldEndWithDot([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where !string.IsNullOrEmpty(template.ShortHelp) && !template.ShortHelp.EndsWith(".") select Warning(context, Msg.C1015, "Template short help text should end with '.'", TraceHelper.GetTextNode(template), template.ItemName)); }
public IEnumerable <IDiagnostic> TemplateShouldHaveShortHelp([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where string.IsNullOrEmpty(template.ShortHelp) select Warning(context, Msg.C1014, "Template should have a short help text", TraceHelper.GetTextNode(template), template.ItemName)); }
protected IEnumerable <IDiagnostic> TemplatesMustLocatedInTemplatesSection([NotNull] ICheckerContext context) { return(from item in context.Project.Items where !item.ItemIdOrPath.StartsWith("/sitecore/templates/") && (item.TemplateName.Equals("Template") || item.TemplateName.Equals("Template section") || item.TemplateName.Equals("Template Field") || item.TemplateName.Equals("Template Folder")) select Warning(context, Msg.C1126, "All items with template 'Template', 'Template section', 'Template field' and 'Template folder' should be located in the '/sitecore/templates' section. To fix, move the template into the '/sitecore/templates' section", TraceHelper.GetTextNode(item), item.TemplateName)); }
public IEnumerable <IDiagnostic> PlaceholdersShouldHaveAPlaceholderSettingsName([NotNull] ICheckerContext context) { return(from rendering in context.Project.ProjectItems.OfType <Rendering>() from placeholder in rendering.Placeholders where context.Project.Items.FirstOrDefault(i => i.ItemName == placeholder && i.TemplateName == "Placeholder") == null select Warning(context, Msg.C1105, "Placeholders should have a Placeholder Settings item", new StringTextNode("Placeholder(\"" + placeholder + "\")", rendering.Snapshot), $"To fix, create a '/sitecore/layout/Placeholder Settings/{placeholder}' item")); }
public IEnumerable <IDiagnostic> PageTypeTemplatesShouldHaveStandardValues([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where IsPageTypeTemplate(template) && template.StandardValuesItem == null select Error(context, Msg.C1091, "Page Type templates should have a Standard Values item. To fix, create a Standard Value item", TraceHelper.GetTextNode(template))); }
public IEnumerable <IDiagnostic> RenderingParametersTemplateMustDeriveFromStandardRenderingParameters([NotNull] ICheckerContext context) { var standardRenderingParametersTemplate = context.Project.ProjectItems.OfType <Template>().FirstOrDefault(t => t.Uri.Guid == StandardRenderingParametersGuid); if (standardRenderingParametersTemplate == null) { return(new[] { Error(context, Msg.C1094, "'StandardRenderingParameters' template not found. Are you missing an import?", SourceFile.Empty) }); } return(from template in context.Project.Templates where IsRenderingParametersTemplate(template) && !template.Is(standardRenderingParametersTemplate) select Error(context, Msg.C1095, "Folder templates should specify Insert Options on their Standard Values item. To fix, assign appropriate Insert Options to the Standard Values item", TraceHelper.GetTextNode(template))); }
public IEnumerable <IDiagnostic> DataSourceTemplatesMustNotHaveLayout([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where IsDataSourceTemplate(template) && HasLayout(template) select Error(context, Msg.C1073, "Data Source Templates must not have a layout. To fix, remove the layout from the template", TraceHelper.GetTextNode(template))); }
public IEnumerable <IDiagnostic> DataSourceTemplatesMustNotFields([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where IsDataSourceTemplate(template) && template.Fields.Any() select Error(context, Msg.C1072, "Page Type Templates must not have fields. To fix, move the fields to a Data Template", TraceHelper.GetTextNode(template))); }
public IEnumerable <IDiagnostic> AvoidUsingFolderTemplate([NotNull] ICheckerContext context) { return(from item in context.Project.Items where item.TemplateName == "Folder" select Warning(context, Msg.C1068, "Avoid using the 'Folder' template. To fix, create a new 'Folder' template, assign Insert Options and change the template of this item", TraceHelper.GetTextNode(item))); }
public IEnumerable <IDiagnostic> PageTypeTemplatesMustHaveLayout([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where IsPageTypeTemplate(template) && !HasLayout(template) select Error(context, Msg.C1087, "Page Type Templates must have a layout. To fix, assign a layout to the template", TraceHelper.GetTextNode(template))); }
public abstract void Check(ICheckerContext context);
public IEnumerable <IDiagnostic> AvoidEmptyTemplate([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where !template.Sections.Any() && template.BaseTemplates == Constants.Templates.StandardTemplateId select Warning(context, Msg.C1013, "Empty templates should be avoided. Consider using the 'Folder' template instead", TraceHelper.GetTextNode(template), template.ItemName)); }
public IEnumerable <IDiagnostic> TemplateFieldLongHelpShouldStartWithCapitalLetter([NotNull] ICheckerContext context) { return(from template in context.Project.Templates from field in template.Fields where !string.IsNullOrEmpty(field.LongHelp) && !char.IsUpper(template.LongHelp[0]) select Warning(context, Msg.C1018, "Template field long help text should start with a capital letter", TraceHelper.GetTextNode(field.LongHelpProperty, field), field.FieldName)); }
public IEnumerable <IDiagnostic> DeleteUnusedTemplates([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where !context.Project.Items.Any(i => i.References.Any(r => r.Resolve() == template)) && !context.Project.Templates.Any(i => i.References.Any(r => r.Resolve() == template)) select Warning(context, Msg.C1025, "Template is not referenced and can be deleted", TraceHelper.GetTextNode(template), template.ItemName)); }
public IEnumerable <IDiagnostic> TemplateShortHelpShouldStartWithCapitalLetter([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where !string.IsNullOrEmpty(template.ShortHelp) && !char.IsUpper(template.ShortHelp[0]) select Warning(context, Msg.C1016, "Template short help text should start with a capital letter", TraceHelper.GetTextNode(template), template.ItemName)); }
protected IEnumerable <IDiagnostic> AvoidSettingSharedAndUnversionedInItems([NotNull] ICheckerContext context) { return(from item in context.Project.Items where item.TemplateName.Equals("Template field") && item[Constants.FieldNames.Shared].Equals("True") && item[Constants.FieldNames.Unversioned].Equals("True") select Warning(context, Msg.C1119, "In a template field, the 'Shared' field overrides the 'Unversioned' field. To fix, clear the 'Unversioned' field (the field remains shared)", TraceHelper.GetTextNode(item), item.ItemName)); }
public IEnumerable <IDiagnostic> FieldContainsLoremIpsum([NotNull] ICheckerContext context) { return(from field in context.Project.Items.SelectMany(i => i.Fields) where field.Value.IndexOf("Lorem Ipsum", StringComparison.OrdinalIgnoreCase) >= 0 select Warning(context, Msg.C1008, "Field contains 'Lorem Ipsum' text", TraceHelper.GetTextNode(field.ValueProperty, field.FieldNameProperty, field), $"The field \"{field.FieldName}\" contains the test data text: \"Lorem Ipsum...\". Replace or remove the text data.")); }
protected IEnumerable <IDiagnostic> AvoidSettingSharedAndUnversionedInTemplates([NotNull] ICheckerContext context) { return(from template in context.Project.Templates from templateSection in template.Sections from templateField in templateSection.Fields where templateField.Shared && templateField.Unversioned select Warning(context, Msg.C1120, "In a template field, the 'Shared' field overrides the 'Unversioned' field. To fix, clear the 'Unversioned' field (the field remains shared)", TraceHelper.GetTextNode(templateField, template), templateField.FieldName)); }
public override void Check(ICheckerContext context) { foreach (var configFile in context.Project.ProjectItems.OfType<ConfigFile>()) { var fileName = configFile.Snapshots.First().SourceFile.AbsoluteFileName; XDocument doc; try { doc = XDocument.Load(fileName, LoadOptions.SetLineInfo); } catch (XmlException ex) { context.Trace.TraceError(Msg.C1055, ex.Message, fileName, new TextSpan(ex.LineNumber, ex.LinePosition, 0)); continue; } catch (Exception ex) { context.Trace.TraceError(Msg.C1056, ex.Message, fileName, TextSpan.Empty); continue; } var elements = doc.XPathSelectElements("//*[@type]"); foreach (var element in elements) { var typeName = element.GetAttributeValue("type"); if (string.IsNullOrEmpty(typeName)) { continue; } if (typeName == "both") { continue; } typeName = typeName.Replace(", mscorlib", string.Empty).Replace(",mscorlib", string.Empty); var assemblyName = string.Empty; var n = typeName.IndexOf(','); if (n >= 0) { assemblyName = typeName.Mid(n + 1).Trim(); typeName = typeName.Left(n).Trim(); } // add '.dll' extension if (!string.IsNullOrEmpty(assemblyName) && !assemblyName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { assemblyName += ".dll"; } Type type = null; try { if (!string.IsNullOrEmpty(assemblyName)) { var binFile = context.Project.ProjectItems.OfType<BinFile>().FirstOrDefault(f => string.Equals(f.ShortName, assemblyName, StringComparison.OrdinalIgnoreCase)); if (binFile != null) { type = GetTypeFromAssembly(binFile, typeName); } } else { foreach (var binFile in context.Project.ProjectItems.OfType<BinFile>()) { type = GetTypeFromAssembly(binFile, typeName); if (type != null) { break; } } } } catch { type = null; } if (type != null) { continue; } var lineInfo = (IXmlLineInfo)element; var textSpan = lineInfo != null ? new TextSpan(lineInfo.LineNumber, lineInfo.LinePosition, 0) : TextSpan.Empty; context.Trace.TraceWarning(Msg.C1054, "Type does not exist in a referenced assembly", fileName, textSpan, element.GetAttributeValue("type")); } } }
protected IEnumerable <IDiagnostic> TemplateIdOfStandardValuesShouldMatchParentId([NotNull] ICheckerContext context) { return(from item in context.Project.Items let parent = item.GetParent() where parent != null && item.Paths.IsStandardValuesHolder && item.Template.Uri.Guid != parent.Uri.Guid select Error(context, Msg.C1122, "The Template ID of a Standard Values item should be match the ID of the parent item. To fix, moved the Standard Values item under the correct template", TraceHelper.GetTextNode(item), details : item.ItemName)); }
public IEnumerable <IDiagnostic> FolderTemplatesShouldHaveInsertOptions([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where template.ItemName.EndsWith("Folder") && template.StandardValuesItem != null && string.IsNullOrEmpty(template.StandardValuesItem["__Masters"]) select Error(context, Msg.C1079, "Folder templates should specify Insert Options on their Standard Values item. To fix, assign appropriate Insert Options to the Standard Values item", TraceHelper.GetTextNode(template))); }
protected IEnumerable <IDiagnostic> TemplateMustLocatedInTemplatesSection([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where !template.ItemIdOrPath.StartsWith("/sitecore/templates/") select Warning(context, Msg.C1123, "All templates should be located in the '/sitecore/templates' section. To fix, move the template into the '/sitecore/templates' section", TraceHelper.GetTextNode(template), template.ItemName)); }
public IEnumerable <IDiagnostic> FolderTemplatesMustNotHaveFields([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where template.ItemName.EndsWith("Folder") && template.Fields.Any() select Error(context, Msg.C1078, "Folder templates must not have any fields. To fix, remove the fields", TraceHelper.GetTextNode(template))); }
protected IEnumerable <IDiagnostic> TemplateNodeOrFolderShouldBeTemplateFolder([NotNull] ICheckerContext context) { return(from item in context.Project.Items where item.ItemIdOrPath.StartsWith("/sitecore/templates/") && (item.TemplateName.Equals("Folder") || item.TemplateName.Equals("Node")) select Warning(context, Msg.C1124, "In the '/sitecore/templates' section, folder items use the 'Template folder' template - not the 'Folder' or 'Node' template. To fix, change the template of the item to 'Template Folder", TraceHelper.GetTextNode(item), item.ItemIdOrPath)); }
public IEnumerable <IDiagnostic> FolderTemplatesMustHaveFolderPostfix([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where !IsDataSourceTemplate(template) && !IsPageTypeTemplate(template) && !IsRenderingParametersTemplate(template) && !template.Fields.Any() && !template.ItemName.EndsWith("Folder") select Warning(context, Msg.C1077, $"Templates without fields should have the 'Folder' postfix. To fix, rename the template to '{template.ItemName}Folder'", TraceHelper.GetTextNode(template))); }
protected IEnumerable <IDiagnostic> TemplateSectionShouldOnlyContainTemplates([NotNull] ICheckerContext context) { return(from item in context.Project.Items where item.ItemIdOrPath.StartsWith("/sitecore/templates/") && item.ItemIdOrPath.IndexOf("Branches", StringComparison.Ordinal) < 0 && !item.Paths.IsStandardValuesHolder && !item.TemplateName.Equals("Template") && !item.TemplateName.Equals("Template section") && !item.TemplateName.Equals("Template field") && !item.TemplateName.Equals("Template Folder") && !item.TemplateName.Equals("Node") && !item.TemplateName.Equals("Folder") && !item.TemplateName.Equals("Command Template") select Warning(context, Msg.C1125, "The '/sitecore/templates' section should only contain item with template 'Template', 'Template section', 'Template field', 'Template folder' or standard values items. To fix, move the item outside the '/sitecore/templates' section", TraceHelper.GetTextNode(item), item.TemplateName)); }
public IEnumerable <IDiagnostic> AvoidSpacesInTemplateNames([NotNull] ICheckerContext context) { return(from template in context.Project.Templates where template.ItemName.IndexOf(' ') >= 0 select Warning(context, Msg.C1012, "Avoid spaces in template names. Use a display name instead", TraceHelper.GetTextNode(template.ItemNameProperty, template), template.ItemName)); }
public IEnumerable <IDiagnostic> RenderingShouldBeInViewsFolder([NotNull] ICheckerContext context) { return(from rendering in context.Project.ProjectItems.OfType <Rendering>() where !rendering.FilePath.StartsWith("~/views/", StringComparison.OrdinalIgnoreCase) select Warning(context, Msg.C1096, "View rendering should be located in the ~/views/ directory", rendering.Snapshot.SourceFile, "To fix, move the file to the ~/views/ directory")); }