aboutsummaryrefslogtreecommitdiff
path: root/exampleData/ruleSets
diff options
context:
space:
mode:
authorGravatar Benjamin Jones <bjones@galois.com>2012-12-07 16:50:16 -0800
committerGravatar Benjamin Jones <bjones@galois.com>2012-12-07 16:50:16 -0800
commit90c7ea900e02e1fd3ec5399e15b00a68b9ae65db (patch)
treeae2591f522366a0742f045aecef3a18b8e3385cb /exampleData/ruleSets
parentb161edf0898d5e73a0643da89444d18da208580e (diff)
added comments so buildCombinedRules.sh script will work
Diffstat (limited to 'exampleData/ruleSets')
-rw-r--r--exampleData/ruleSets/README2
-rw-r--r--exampleData/ruleSets/alwaysErrThreeTimes.json12
-rwxr-xr-xexampleData/ruleSets/buildCombinedRules.sh3
-rw-r--r--exampleData/ruleSets/combinedRules.json113
-rw-r--r--exampleData/ruleSets/emptyHeadings.json7
-rw-r--r--exampleData/ruleSets/headingGuidelines.json68
-rw-r--r--exampleData/ruleSets/reportOnSampleText.json10
-rw-r--r--exampleData/ruleSets/ruleSet1.json8
-rw-r--r--exampleData/ruleSets/simpleRuleSet1.json9
-rw-r--r--exampleData/ruleSets/template.json4
-rw-r--r--exampleData/ruleSets/trivialReport.json8
11 files changed, 195 insertions, 49 deletions
diff --git a/exampleData/ruleSets/README b/exampleData/ruleSets/README
index 48d55ff..10a3269 100644
--- a/exampleData/ruleSets/README
+++ b/exampleData/ruleSets/README
@@ -12,4 +12,4 @@ textRules.json : rules checking text style
buildCombinedRules.sh : shell script which merges all the .json files in
the current directory into the file combinedRules.json
-combinedRules.json : collection of all the above rules in one file
+combinedRules.json : collection of all the above rules in the directory into one file
diff --git a/exampleData/ruleSets/alwaysErrThreeTimes.json b/exampleData/ruleSets/alwaysErrThreeTimes.json
index 9060f5d..24b0b62 100644
--- a/exampleData/ruleSets/alwaysErrThreeTimes.json
+++ b/exampleData/ruleSets/alwaysErrThreeTimes.json
@@ -1,6 +1,8 @@
{ "name": "always errors"
, "description": "A trivial rule set for experimentation."
-, "rules": [ { "id":13
+, "rules": [
+//---------------------------------
+ { "id":13
, "name": "Reports three times"
, "description": "Test guideline that reports three errors"
, "rule":
@@ -9,8 +11,9 @@
report('Problem 3 (g1)', null);
report('Problem 2 (g1)', null);
}
- }
- , { "id":14
+ },
+//---------------------------------
+ { "id":14
, "name": "Reports two times"
, "description": "Test guideline that reports two errors."
, "rule":
@@ -18,6 +21,7 @@
report('Problem 1 (g2)', null);
report('Problem 2 (g2)', null);
}
- }
+ }//,
+//---------------------------------
]
}
diff --git a/exampleData/ruleSets/buildCombinedRules.sh b/exampleData/ruleSets/buildCombinedRules.sh
index df4782d..f4bad1c 100755
--- a/exampleData/ruleSets/buildCombinedRules.sh
+++ b/exampleData/ruleSets/buildCombinedRules.sh
@@ -3,6 +3,9 @@
# This script builds a collection of FiveUI rulesets (contained in various .json files)
# into a combined rule sets file: combinedRules.json.
#
+# For the script to work, the input .json files must have rules separated by
+# comment lines starting with //---. Also, the last rule in the file must be
+# followed by //,. See colorRules.json for an example.
FILES=`ls *.json | grep -v combinedRules`
OUTFILE="combinedRules.json"
diff --git a/exampleData/ruleSets/combinedRules.json b/exampleData/ruleSets/combinedRules.json
index bddfd5a..5aa573d 100644
--- a/exampleData/ruleSets/combinedRules.json
+++ b/exampleData/ruleSets/combinedRules.json
@@ -1,6 +1,27 @@
{ 'name': "Combined color, font, image, and text rules"
, 'description': "Site colors, fonts, images, and text should conform to these general guidelines"
, 'rules': [
+//---------------------------------
+ { "id":13
+ , "name": "Reports three times"
+ , "description": "Test guideline that reports three errors"
+ , "rule":
+ function() {
+ report('Problem 1 (g1)', null);
+ report('Problem 3 (g1)', null);
+ report('Problem 2 (g1)', null);
+ }
+ },
+//---------------------------------
+ { "id":14
+ , "name": "Reports two times"
+ , "description": "Test guideline that reports two errors."
+ , "rule":
+ function() {
+ report('Problem 1 (g2)', null);
+ report('Problem 2 (g2)', null);
+ }
+ },
//----------------------------------------------------------------
{ 'name': "Foreground check"
, 'description': "Foreground colors should be in the set:"+
@@ -76,6 +97,17 @@
});
}
},
+ //---
+ { "id": 1, "name": "Disallow Empty Headers"
+ , "description": "Heading elements should contain text."
+ , "rule": function() {
+ fiveui.query(':header').each(function(ix, elt) {
+ if($(elt).text() == '') {
+ report('Heading does not contain text', elt);
+ }
+ });
+ }
+ },
//---------------------------------------------------------
{ 'name': "Font properties check"
, 'description': "Verify that fonts (family, size, weight) are \"standard\""
@@ -96,6 +128,41 @@
});
}
},
+//------------
+ { "id": 1
+ , "name": "Headings are capitalized"
+ , "description": "Check to see if all headings use leading capital letters"
+ , "rule":
+ function() {
+ var badHeadings =
+ fiveui.query(':header').filter(
+ function(idx) {
+ var ch = $(this).text()[0];
+ if (ch) {
+ return (ch == ch.toLowerCase() );
+ } else {
+ return false;
+ }
+ });
+ $(badHeadings).map(function(idx, elt){
+ report('Heading does not start with a capital letter', elt);
+ });
+
+ }
+ },
+//------------
+ { "id": 2
+ , "name": "Disallow Empty Headers"
+ , "description": "Heading elements should contain text"
+ , "rule": function() {
+ fiveui.query(':header').each(
+ function(ix, elt) {
+ if($(elt).text() == '') {
+ report('Heading does not contain text', elt);
+ }
+ });
+ }
+ },
//----------------------------------------------------------------
{ 'name': "Banner check"
, 'description': "Banner image banner.gif must appear and link to somewhere"
@@ -182,6 +249,47 @@
}
}
},
+//---
+ { 'name': 'Test rule',
+ 'description': 'An empty test rule',
+ 'rule': function() {
+ fiveui.query('p').each(
+ function(idx, elt) {
+ if ($(elt).text().indexOf('Sample text') != -1) {
+ report('test error', elt);
+ }
+ });
+ }
+ },
+ //---
+ {"id":42,"name":"r1","description":"desc1","rule":"rule txt1"},
+ //---
+ {"id":43,"name":"r2","description":"desc2","rule":"rule txt2"},
+//---
+ { "id":42
+ , "name": "Headings are capitalized"
+ , "description": "Check to see if all h1 headings use leading capital letters."
+ , "rule":
+ function() {
+ var badHeadings = $('h1').filter(function(idx) {
+ var ch = $(this).text()[0];
+ if (ch) {
+ return (ch == ch.toLowerCase() );
+ } else {
+ return false;
+ }
+ });
+ $(badHeadings).map(function(idx, elt){
+ report('Heading does not start with a capitol letter.', elt);
+ });
+
+ },
+//--------------------------------------------
+ { 'name': "RULE NAME"
+ , 'description': "RULE DESC"
+ , 'rule':
+ function() {} // Function that checks the rule
+ },
//---------------------------------------------------------------
{ "id": 13
, "name": "Sentence case"
@@ -232,5 +340,10 @@
report('"Galwegian" should be capitalized', elt);
})
}
+ },
+//-----------------------------------
+ { 'id': 1, 'name': 'Test rule',
+ 'description': 'An empty test rule',
+ 'rule': function() { report('test error'); }
}
]}
diff --git a/exampleData/ruleSets/emptyHeadings.json b/exampleData/ruleSets/emptyHeadings.json
index 0b0020a..b1aa94d 100644
--- a/exampleData/ruleSets/emptyHeadings.json
+++ b/exampleData/ruleSets/emptyHeadings.json
@@ -1,7 +1,9 @@
{ "name": "Header Rule Set"
, "description": "Simple rules about HTML headers."
, "rules":
- [ { "id": 1, "name": "Disallow Empty Headers"
+ [
+ //---
+ { "id": 1, "name": "Disallow Empty Headers"
, "description": "Heading elements should contain text."
, "rule": function() {
fiveui.query(':header').each(function(ix, elt) {
@@ -10,6 +12,7 @@
}
});
}
- }
+ }//,
+ //---
]
}
diff --git a/exampleData/ruleSets/headingGuidelines.json b/exampleData/ruleSets/headingGuidelines.json
index 886ea07..6942515 100644
--- a/exampleData/ruleSets/headingGuidelines.json
+++ b/exampleData/ruleSets/headingGuidelines.json
@@ -1,37 +1,41 @@
{ "name": "Heading Guidelines"
, "description": "Guidelines pertaining to the formatting and content of headings"
-, "rules": [ { "id": 1
- , "name": "Headings are capitalized"
- , "description": "Check to see if all headings use leading capital letters"
- , "rule":
- function() {
- var badHeadings =
- fiveui.query(':header').filter(
- function(idx) {
- var ch = $(this).text()[0];
- if (ch) {
- return (ch == ch.toLowerCase() );
- } else {
- return false;
- }
- });
- $(badHeadings).map(function(idx, elt){
- report('Heading does not start with a capital letter', elt);
- });
+, "rules": [
+//------------
+ { "id": 1
+ , "name": "Headings are capitalized"
+ , "description": "Check to see if all headings use leading capital letters"
+ , "rule":
+ function() {
+ var badHeadings =
+ fiveui.query(':header').filter(
+ function(idx) {
+ var ch = $(this).text()[0];
+ if (ch) {
+ return (ch == ch.toLowerCase() );
+ } else {
+ return false;
+ }
+ });
+ $(badHeadings).map(function(idx, elt){
+ report('Heading does not start with a capital letter', elt);
+ });
- }
- },
- { "id": 2
- , "name": "Disallow Empty Headers"
- , "description": "Heading elements should contain text"
- , "rule": function() {
- fiveui.query(':header').each(
- function(ix, elt) {
- if($(elt).text() == '') {
- report('Heading does not contain text', elt);
- }
- });
- }
- }
+ }
+ },
+//------------
+ { "id": 2
+ , "name": "Disallow Empty Headers"
+ , "description": "Heading elements should contain text"
+ , "rule": function() {
+ fiveui.query(':header').each(
+ function(ix, elt) {
+ if($(elt).text() == '') {
+ report('Heading does not contain text', elt);
+ }
+ });
+ }
+ }//,
+//------------
]
}
diff --git a/exampleData/ruleSets/reportOnSampleText.json b/exampleData/ruleSets/reportOnSampleText.json
index af4e2b8..143e629 100644
--- a/exampleData/ruleSets/reportOnSampleText.json
+++ b/exampleData/ruleSets/reportOnSampleText.json
@@ -1,6 +1,8 @@
{ 'name': 'reportOnSampleText',
'description': 'test',
- 'rules': [ { 'name': 'Test rule',
+ 'rules': [
+//---
+ { 'name': 'Test rule',
'description': 'An empty test rule',
'rule': function() {
fiveui.query('p').each(
@@ -10,5 +12,7 @@
}
});
}
- } ]
-} \ No newline at end of file
+ }//,
+ //----
+ ]
+}
diff --git a/exampleData/ruleSets/ruleSet1.json b/exampleData/ruleSets/ruleSet1.json
index d66b614..b4cfcb3 100644
--- a/exampleData/ruleSets/ruleSet1.json
+++ b/exampleData/ruleSets/ruleSet1.json
@@ -1 +1,7 @@
-{"id":42,"name":"Rule Set","description":"rule set description","rules":[{"id":42,"name":"r1","description":"desc1","rule":"rule txt1"},{"id":43,"name":"r2","description":"desc2","rule":"rule txt2"}]} \ No newline at end of file
+{"id":42,"name":"Rule Set","description":"rule set description","rules":[
+ //---
+ {"id":42,"name":"r1","description":"desc1","rule":"rule txt1"},
+ //---
+ {"id":43,"name":"r2","description":"desc2","rule":"rule txt2"}//,
+ //---
+ ]}
diff --git a/exampleData/ruleSets/simpleRuleSet1.json b/exampleData/ruleSets/simpleRuleSet1.json
index 6c5bccb..5b4fd95 100644
--- a/exampleData/ruleSets/simpleRuleSet1.json
+++ b/exampleData/ruleSets/simpleRuleSet1.json
@@ -1,6 +1,8 @@
{ "name": "Simple Rule Set 1"
, "description": "A trivila rule set for experimentation."
-, "rules": [ { "id":42
+, "rules": [
+//---
+ { "id":42
, "name": "Headings are capitalized"
, "description": "Check to see if all h1 headings use leading capital letters."
, "rule":
@@ -17,6 +19,7 @@
report('Heading does not start with a capitol letter.', elt);
});
- }
+ }//,
+//---
}]
-} \ No newline at end of file
+}
diff --git a/exampleData/ruleSets/template.json b/exampleData/ruleSets/template.json
index 3d098c7..70d101c 100644
--- a/exampleData/ruleSets/template.json
+++ b/exampleData/ruleSets/template.json
@@ -8,10 +8,12 @@
{ 'name': "NAME"
, 'description': "DESCRIPTION"
, 'rules': [
+//--------------------------------------------
{ 'name': "RULE NAME"
, 'description': "RULE DESC"
, 'rule':
function() {} // Function that checks the rule
- },
+ }//,
+//--------------------------------------------
]
}
diff --git a/exampleData/ruleSets/trivialReport.json b/exampleData/ruleSets/trivialReport.json
index 89ac798..4b2d11f 100644
--- a/exampleData/ruleSets/trivialReport.json
+++ b/exampleData/ruleSets/trivialReport.json
@@ -1,7 +1,11 @@
{ 'name': 'Test rule set',
'description': 'test',
- 'rules': [ { 'id': 1, 'name': 'Test rule',
+ 'rules': [
+//-----------------------------------
+ { 'id': 1, 'name': 'Test rule',
'description': 'An empty test rule',
'rule': function() { report('test error'); }
- } ]
+ }//,
+//-----------------------------------
+]
}