Skip to content

Commit

Permalink
Merge pull request #12 from NatVanG/newrules
Browse files Browse the repository at this point in the history
Newrules
  • Loading branch information
NatVanG authored Oct 3, 2023
2 parents 5512583 + 9bb48a3 commit e2cd3ea
Show file tree
Hide file tree
Showing 47 changed files with 260 additions and 212 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,5 @@ FodyWeavers.xsd
/PBIXInspectorCLI/Files/pbip/.gitignore
/PBIXInspectorTests/Files/pbip/.gitignore
/PBIXInspectorCLI/Properties/PublishProfiles/FolderProfile.pubxml
/PBIXInspectorWinLibrary/Files/pbip/Inventory sample - fails.Dataset/.pbi/localSettings.json
/PBIXInspectorWinLibrary/Files/pbip/Inventory sample - fails.Report/.pbi/localSettings.json
112 changes: 51 additions & 61 deletions DocsExamples/Example rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,67 +158,6 @@
[]
]
},
{
"name": "Ensure charts use theme colours except textboxes",
"description": "Check that charts avoid custom colours and use theme colours instead.",
"disabled": false,
"logType": "warning",
"forEachPath": "$.sections[*]",
"forEachPathName": "$.name",
"forEachPathDisplayName": "$.displayName",
"path": "$.visualContainers[*].config",
"pathErrorWhenNoMatch": false,
"test": [
{
"map": [
{
"filter": [
{
"var": "visualsConfigArray"
},
{
"and": [
{
"!": [
{
"in": [
{
"var": "singleVisual.visualType"
},
[
"textbox"
]
]
}
]
},
{
"strcontains": [
{
"tostring": [
{
"var": ""
}
]
},
"#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})"
]
}
]
}
]
},
{
"var": "name"
}
]
},
{
"visualsConfigArray": "."
},
[]
]
},
{
"name": "Percentage of charts across the report using custom colours is not greater than 10%",
"description": "Check that charts avoid custom colours and use theme colours instead.",
Expand Down Expand Up @@ -308,6 +247,57 @@
},
true
]
},
{
"name": "Ensure alternativeText has been defined for all visuals",
"description": "Alt-text is required for screen readers",
"disabled": false,
"logType": "warning",
"forEachPath": "$.sections[*]",
"forEachPathName": "$.name",
"forEachPathDisplayName": "$.displayName",
"path": "$.visualContainers[*].config",
"pathErrorWhenNoMatch": false,
"test": [
{
"map": [
{
"filter": [
{
"var": "visualsConfigArray"
},
{
"none": [
{
"var": "singleVisual.vcObjects.general"
},
{
"or": [
{
"!!": [ { "var": "properties.altText.expr.Aggregation" } ]
},
{
"!=": [
{ "var": "properties.altText.expr.Literal.Value" },
"''"
]
}
]
}
]
}
]
},
{
"var": "name"
}
]
},
{
"visualsConfigArray": "."
},
[]
]
}
]
}
Expand Down
6 changes: 6 additions & 0 deletions PBIXInspector.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DocsExamples", "DocsExample
DocsExamples\Example rules.json = DocsExamples\Example rules.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rules", "Rules", "{BB86A63C-BBD5-48DA-9481-343165781823}"
ProjectSection(SolutionItems) = preProject
Rules\Base rules.json = Rules\Base rules.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -66,6 +71,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{AD4E6E10-AD07-4A1E-B6D4-258C5BCF261F} = {D842426E-4F0A-42E7-8574-3D8C739651F1}
{0DABAA35-C96D-4D84-96ED-C088A39D5CA0} = {D842426E-4F0A-42E7-8574-3D8C739651F1}
{BB86A63C-BBD5-48DA-9481-343165781823} = {D842426E-4F0A-42E7-8574-3D8C739651F1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {937CBF58-BBEF-4642-AAD3-5156B6BF45CE}
Expand Down
40 changes: 34 additions & 6 deletions PBIXInspectorTests/CLIArgsUtilsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void TestCLIArgsUtilsSuccess_FavourPBIPReportOption()
[Test]
public void TestCLIArgsUtilsPBIX()
{
string[] args = "-pbix pbixPath".Split(" ");
string[] args = "-pbix pbixPath -rules rulespath".Split(" ");
Args? parsedArgs = null;

parsedArgs = ArgsUtils.ParseArgs(args);
Expand All @@ -82,7 +82,7 @@ public void TestCLIArgsUtilsPBIX()
[Test]
public void TestCLIArgsUtilsRules()
{
string[] args = "-rules rulesPath".Split(" ");
string[] args = "-pbipreport path -rules rulesPath".Split(" ");
Args? parsedArgs = null;

parsedArgs = ArgsUtils.ParseArgs(args);
Expand All @@ -93,7 +93,7 @@ public void TestCLIArgsUtilsRules()
[Test]
public void TestCLIArgsUtilsFormats()
{
string[] args = "-formats CONSOLE,HTML,PNG,JSON".Split(" ");
string[] args = "-pbipreport path -rules rulepath -formats CONSOLE,HTML,PNG,JSON".Split(" ");
Args? parsedArgs = null;

parsedArgs = ArgsUtils.ParseArgs(args);
Expand All @@ -104,7 +104,7 @@ public void TestCLIArgsUtilsFormats()
[Test]
public void TestCLIArgsUtilsDefaults()
{
string[] args = "".Split(" ");
string[] args = "-pbipreport path -rules rulespath".Split(" ");
Args? parsedArgs = null;

parsedArgs = ArgsUtils.ParseArgs(args);
Expand All @@ -113,13 +113,41 @@ public void TestCLIArgsUtilsDefaults()
&& !parsedArgs.Verbose
&& parsedArgs.DeleteOutputDirOnExit
&& !string.IsNullOrEmpty(parsedArgs.OutputDirPath)
&& !string.IsNullOrEmpty(parsedArgs.PBIFilePath)
&& !string.IsNullOrEmpty(parsedArgs.RulesFilePath)
&& !parsedArgs.HTMLOutput
&& !parsedArgs.JSONOutput
&& !parsedArgs.PNGOutput);
}

[Test]
public void TestCLIArgsUtilsThrows()
{
string[] args = "-pbipreport pbipreportpath".Split(" ");
Args? parsedArgs = null;

ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
() => parsedArgs = ArgsUtils.ParseArgs(args));
}

[Test]
public void TestCLIArgsUtilsThrows1()
{
string[] args = "-pbix pbixpath".Split(" ");
Args? parsedArgs = null;

ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
() => parsedArgs = ArgsUtils.ParseArgs(args));
}

[Test]
public void TestCLIArgsUtilsThrows2()
{
string[] args = "-rules rulesPath".Split(" ");
Args? parsedArgs = null;

ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
() => parsedArgs = ArgsUtils.ParseArgs(args));
}

[Test]
public void TestCLIArgsUtilsThrows3()
{
Expand Down
Binary file added PBIXInspectorTests/Files/Inventory sample.pbix
Binary file not shown.
23 changes: 11 additions & 12 deletions PBIXInspectorTests/PBIXInspectorTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
</PropertyGroup>

<ItemGroup>
<Content Include="..\PBIXInspectorWinLibrary\Files\Base rules.json" Link="Files\Base rules.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\PBIXInspectorWinLibrary\Files\Inventory rules sample.json" Link="Files\Inventory rules sample.json">
<Content Include="..\PBIXInspectorWinLibrary\Files\ReportPageFieldMap.json" Link="Files\ReportPageFieldMap.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\PBIXInspectorWinLibrary\Files\ReportPageFieldMap.json" Link="Files\ReportPageFieldMap.json">
<Content Include="..\Rules\Base rules.json" Link="Files\Base rules.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand All @@ -40,9 +37,18 @@
</ItemGroup>

<ItemGroup>
<None Update="Files\Inventory rules sample.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory rules test.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory sample - fails.pbix">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory sample.pbix">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory test.pbix">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -85,11 +91,4 @@
<Folder Include="Files\pbip\" />
</ItemGroup>

<ItemGroup>
<None Include="..\PBIXInspectorWinLibrary\Files\Inventory sample - fails.pbix" Link="Files\Inventory sample - fails.pbix" />
<None Include="..\PBIXInspectorWinLibrary\Files\Inventory sample.pbix" Link="Files\Inventory sample.pbix">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"z": 4500.00
},
{
"config": "{\"name\":\"3f7d302598c1e81e7e78\",\"layouts\":[{\"id\":0,\"position\":{\"x\":0,\"y\":142.22222222222223,\"z\":3000,\"width\":1280,\"height\":288.7111111111111,\"tabOrder\":3000}}],\"singleVisual\":{\"visualType\":\"barChart\",\"projections\":{\"Category\":[{\"queryRef\":\"Inventory.Item\",\"active\":true}],\"Y\":[{\"queryRef\":\"Sum(Inventory.Quantity)\"}]},\"prototypeQuery\":{\"Version\":2,\"From\":[{\"Name\":\"i\",\"Entity\":\"Inventory\",\"Type\":0}],\"Select\":[{\"Column\":{\"Expression\":{\"SourceRef\":{\"Source\":\"i\"}},\"Property\":\"Item\"},\"Name\":\"Inventory.Item\"},{\"Aggregation\":{\"Expression\":{\"Column\":{\"Expression\":{\"SourceRef\":{\"Source\":\"i\"}},\"Property\":\"Quantity\"}},\"Function\":0},\"Name\":\"Sum(Inventory.Quantity)\"}],\"OrderBy\":[{\"Direction\":2,\"Expression\":{\"Aggregation\":{\"Expression\":{\"Column\":{\"Expression\":{\"SourceRef\":{\"Source\":\"i\"}},\"Property\":\"Quantity\"}},\"Function\":0}}}]},\"drillFilterOtherVisuals\":true,\"hasDefaultSort\":true,\"vcObjects\":{\"title\":[{\"properties\":{\"text\":{\"expr\":{\"Literal\":{\"Value\":\"'Quantity Bar Chart'\"}}}}}],\"subTitle\":[{\"properties\":{\"show\":{\"expr\":{\"Literal\":{\"Value\":\"true\"}}}}}]}}}",
"config": "{\"name\":\"3f7d302598c1e81e7e78\",\"layouts\":[{\"id\":0,\"position\":{\"x\":0,\"y\":142.22222222222223,\"z\":3000,\"width\":1280,\"height\":288.7111111111111,\"tabOrder\":3000}}],\"singleVisual\":{\"visualType\":\"barChart\",\"projections\":{\"Category\":[{\"queryRef\":\"Inventory.Item\",\"active\":true}],\"Y\":[{\"queryRef\":\"Sum(Inventory.Quantity)\"}]},\"prototypeQuery\":{\"Version\":2,\"From\":[{\"Name\":\"i\",\"Entity\":\"Inventory\",\"Type\":0}],\"Select\":[{\"Column\":{\"Expression\":{\"SourceRef\":{\"Source\":\"i\"}},\"Property\":\"Item\"},\"Name\":\"Inventory.Item\"},{\"Aggregation\":{\"Expression\":{\"Column\":{\"Expression\":{\"SourceRef\":{\"Source\":\"i\"}},\"Property\":\"Quantity\"}},\"Function\":0},\"Name\":\"Sum(Inventory.Quantity)\"}],\"OrderBy\":[{\"Direction\":2,\"Expression\":{\"Aggregation\":{\"Expression\":{\"Column\":{\"Expression\":{\"SourceRef\":{\"Source\":\"i\"}},\"Property\":\"Quantity\"}},\"Function\":0}}}]},\"drillFilterOtherVisuals\":true,\"hasDefaultSort\":true,\"vcObjects\":{\"title\":[{\"properties\":{\"text\":{\"expr\":{\"Literal\":{\"Value\":\"'Quantity Bar Chart'\"}}}}}],\"subTitle\":[{\"properties\":{\"show\":{\"expr\":{\"Literal\":{\"Value\":\"true\"}}}}}],\"general\":[{\"properties\":{\"altText\":{\"expr\":{\"Literal\":{\"Value\":\"'Bar chart showing sum of quantity by item. '\"}}}}}]}}}",
"filters": "[]",
"height": 288.71,
"width": 1280.00,
Expand Down
81 changes: 81 additions & 0 deletions PBIXInspectorWinForm/PBIXInspectorWinForm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<None Remove="pbiinspector.ico" />
</ItemGroup>

<ItemGroup>
<Content Include="..\Rules\Base rules.json" Link="Files\Base rules.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Include="..\LICENSE" Link="LICENSE">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand All @@ -38,6 +44,81 @@
</ItemGroup>

<ItemGroup>
<None Update="Files\pbip\Inventory sample - fails.Dataset\definition.pbidataset">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Dataset\diagramLayout.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Dataset\item.config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Dataset\item.metadata.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Dataset\model.bim">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.pbip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Report\definition.pbir">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Report\item.config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Report\item.metadata.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Report\report.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Report\StaticResources\RegisteredResources\pbilogo011716949638171492.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample - fails.Report\StaticResources\SharedResources\BaseThemes\CY22SU11.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Dataset\definition.pbidataset">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Dataset\diagramLayout.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Dataset\item.config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Dataset\item.metadata.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Dataset\model.bim">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.pbip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Report\datasetDiagramLayout.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Report\definition.pbir">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Report\item.config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Report\item.metadata.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Report\report.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Report\StaticResources\RegisteredResources\pbilogo011716949638171492.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\pbip\Inventory sample.Report\StaticResources\SharedResources\BaseThemes\CY22SU11.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PBIXInspectorWinForm.pbitool.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Binary file removed PBIXInspectorWinLibrary/Files/Inventory sample.pbix
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Loading

0 comments on commit e2cd3ea

Please sign in to comment.