<commit_before>﻿param(
[Parameter(Mandatory=$true,Position=0)]
[string]$TemplateText,

[Parameter(Mandatory=$true,Position=1)]
[string]$TemplateObject,

[Parameter(Mandatory=$true,Position=1)]
[switch]$IsMainTemplate
)
$TemplateObjectCopy = $templateText | ConvertFrom-Json
$TemplateObjectCopy.psobject.properties.remove('parameters')
$TemplateWithoutParameters = $TemplateObjectCopy | 
    ConvertTo-Json -Depth 10        

 
$locationParameter = $templateObject.parameters.location

if ($locationParameter -and 
    $locationParameter.defaultvalue -ne '[resourceGroup().location]' -and 
    $IsMainTemplate) {
    Write-Error "Location parameter must not be hardcoded.  The default value should be [resourceGroup().location]." -ErrorId Location.Parameter.Hardcoded -TargetObject $parameter
}

if ($TemplateWithoutParameters -like '*resourceGroup().location*') {
    Write-Error "$TemplateFileName must use the location parameter, not resourceGroup().location (except when used as a default value)" -ErrorId Location.Parameter.Should.Be.Used -TargetObject $parameter
}<commit_msg>Expanding Location Test to Cover bad uses of Location in other Parameters<commit_after>﻿param(
[Parameter(Mandatory=$true,Position=0)]
[string]$TemplateText,

[Parameter(Mandatory=$true,Position=1)]
[string]$TemplateObject,

[Parameter(Mandatory=$true,Position=1)]
[switch]$IsMainTemplate
)
$TemplateObjectCopy = $templateText | ConvertFrom-Json
$TemplateObjectCopy.parameters.psobject.properties.remove('location')
$TemplateWithoutLocationParameter = $TemplateObjectCopy | 
    ConvertTo-Json -Depth 10        

 
$locationParameter = $templateObject.parameters.location

if ($locationParameter -and 
    $locationParameter.defaultvalue -ne '[resourceGroup().location]' -and 
    $IsMainTemplate) {
    Write-Error "Location parameter must not be hardcoded.  The default value should be [resourceGroup().location]." -ErrorId Location.Parameter.Hardcoded -TargetObject $parameter
}

if ($TemplateWithoutLocationParameter -like '*resourceGroup().location*') {
    Write-Error "$TemplateFileName must use the location parameter, not resourceGroup().location (except when used as a default value)" -ErrorId Location.Parameter.Should.Be.Used -TargetObject $parameter
}
{'fraction_non_alphanumeric': 0.11188506747932085, 'fraction_numerical': 0.0043535045711798, 'mean_word_length': 5.436974789915967, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3877570', 'n_tokens_mistral': 632, 'n_tokens_neox': 607, 'n_words': 145}