Skip to content

Revert "Only Trigger PSProvideVerboseMessage in Advanced Scripts or F… #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions Rules/ProvideVerboseMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation.Language;
using Microsoft.Windows.Powershell.ScriptAnalyzer.Generic;
using System.ComponentModel.Composition;
using System.Globalization;
using System.Management.Automation;

namespace Microsoft.Windows.Powershell.ScriptAnalyzer.BuiltinRules
{
Expand All @@ -35,11 +33,11 @@ public class ProvideVerboseMessage : SkipNamedBlock, IScriptRule
public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
{
if (ast == null) throw new ArgumentNullException(Strings.NullAstErrorMessage);

ClearList();
this.AddNames(new List<string>() { "Configuration", "Workflow" });
DiagnosticRecords.Clear();

this.fileName = fileName;
//We only check that advanced functions should have Write-Verbose
ast.Visit(this);
Expand All @@ -59,17 +57,6 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun
return AstVisitAction.SkipChildren;
}

//Write-Verbose is not required for non-advanced functions
if (funcAst.Body != null && funcAst.Body.ParamBlock != null
&& funcAst.Body.ParamBlock.Attributes != null &&
funcAst.Body.ParamBlock.Parameters != null)
{
if (!funcAst.Body.ParamBlock.Attributes.Any(attr => attr.TypeName.GetReflectionType() == typeof(CmdletBindingAttribute)))
{
return AstVisitAction.Continue;
}
}

var commandAsts = funcAst.Body.FindAll(testAst => testAst is CommandAst, false);
bool hasVerbose = false;

Expand Down