• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MeindertN / RoboClerk / 15744196809

18 Jun 2025 05:49PM UTC coverage: 83.445% (+3.5%) from 79.923%
15744196809

push

github

web-flow
Merge pull request #62 from MeindertN/V1.5.0

V1.5.0

1574 of 1915 branches covered (82.19%)

Branch coverage included in aggregate %.

868 of 1110 new or added lines in 27 files covered. (78.2%)

6 existing lines in 2 files now uncovered.

5029 of 5998 relevant lines covered (83.84%)

108.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.43
/RoboClerk/PluginSupport/DataSourcePluginBase.cs
1
using System;
2
using System.Collections.Generic;
3
using System.IO.Abstractions;
4
using System.Reflection;
5
using System.Text;
6
using System.Text.RegularExpressions;
7

8
namespace RoboClerk
9
{
10
    public abstract class DataSourcePluginBase : PluginBase, IDataSourcePlugin
11
    {
12
        protected List<RequirementItem> systemRequirements = new List<RequirementItem>();
59✔
13
        protected List<RequirementItem> softwareRequirements = new List<RequirementItem>();
59✔
14
        protected List<RequirementItem> documentationRequirements = new List<RequirementItem>();
59✔
15
        protected List<SoftwareSystemTestItem> testCases = new List<SoftwareSystemTestItem>();
59✔
16
        protected List<AnomalyItem> anomalies = new List<AnomalyItem>();
59✔
17
        protected List<RiskItem> risks = new List<RiskItem>();
59✔
18
        protected List<SOUPItem> soup = new List<SOUPItem>();
59✔
19
        protected List<DocContentItem> docContents = new List<DocContentItem>();
59✔
20
        protected List<UnitTestItem> unitTests = new List<UnitTestItem>();
59✔
21
        protected List<ExternalDependency> dependencies = new List<ExternalDependency>();
59✔
22
        protected List<TestResult> testResults = new List<TestResult>();
59✔
23
        //we also keep track of any items that have been eliminated
24
        protected List<EliminatedRequirementItem> eliminatedSystemRequirements = new List<EliminatedRequirementItem>();
59✔
25
        protected List<EliminatedRequirementItem> eliminatedSoftwareRequirements = new List<EliminatedRequirementItem>();
59✔
26
        protected List<EliminatedRequirementItem> eliminatedDocumentationRequirements = new List<EliminatedRequirementItem>();
59✔
27
        protected List<EliminatedSoftwareSystemTestItem> eliminatedSoftwareSystemTests = new List<EliminatedSoftwareSystemTestItem>();
59✔
28
        protected List<EliminatedRiskItem> eliminatedRisks = new List<EliminatedRiskItem>();
59✔
29
        protected List<EliminatedDocContentItem> eliminatedDocContents = new List<EliminatedDocContentItem>();
59✔
30
        protected List<EliminatedSOUPItem> eliminatedSOUP = new List<EliminatedSOUPItem>();
59✔
31
        protected List<EliminatedAnomalyItem> eliminatedAnomalies = new List<EliminatedAnomalyItem>();
59✔
32

33
        public DataSourcePluginBase(IFileSystem fileSystem)
34
            :base(fileSystem)
59✔
35
        {
59✔
36

37
        }
59✔
38

39
        public abstract void RefreshItems();
40

41
        public IEnumerable<AnomalyItem> GetAnomalies()
42
        {
4✔
43
            return anomalies;
4✔
44
        }
4✔
45

46
        public IEnumerable<RequirementItem> GetSystemRequirements()
47
        {
4✔
48
            return systemRequirements;
4✔
49
        }
4✔
50

51
        public IEnumerable<RequirementItem> GetSoftwareRequirements()
52
        {
4✔
53
            return softwareRequirements;
4✔
54
        }
4✔
55

56
        public IEnumerable<RequirementItem> GetDocumentationRequirements()
57
        {
4✔
58
            return documentationRequirements;
4✔
59
        }
4✔
60

61
        public IEnumerable<DocContentItem> GetDocContents()
62
        {
4✔
63
            return docContents;
4✔
64
        }
4✔
65

66
        public IEnumerable<SoftwareSystemTestItem> GetSoftwareSystemTests()
67
        {
6✔
68
            return testCases;
6✔
69
        }
6✔
70

71
        public IEnumerable<RiskItem> GetRisks()
72
        {
4✔
73
            return risks;
4✔
74
        }
4✔
75

76
        public IEnumerable<SOUPItem> GetSOUP()
77
        {
4✔
78
            return soup;
4✔
79
        }
4✔
80

81
        public IEnumerable<UnitTestItem> GetUnitTests()
82
        {
3✔
83
            return unitTests;
3✔
84
        }
3✔
85

86
        public IEnumerable<ExternalDependency> GetDependencies()
87
        {
×
88
            return dependencies;
×
89
        }
×
90

91
        public IEnumerable<TestResult> GetTestResults()
NEW
92
        {
×
NEW
93
            return testResults;
×
NEW
94
        }
×
95

96
        public IEnumerable<EliminatedRequirementItem> GetEliminatedSystemRequirements()
97
        {
4✔
98
            return eliminatedSystemRequirements;
4✔
99
        }
4✔
100

101
        public IEnumerable<EliminatedRequirementItem> GetEliminatedSoftwareRequirements()
102
        {
2✔
103
            return eliminatedSoftwareRequirements;
2✔
104
        }
2✔
105

106
        public IEnumerable<EliminatedRequirementItem> GetEliminatedDocumentationRequirements()
107
        {
2✔
108
            return eliminatedDocumentationRequirements;
2✔
109
        }
2✔
110

111
        public IEnumerable<EliminatedSoftwareSystemTestItem> GetEliminatedSoftwareSystemTests()
112
        {
2✔
113
            return eliminatedSoftwareSystemTests;
2✔
114
        }
2✔
115

116
        public IEnumerable<EliminatedRiskItem> GetEliminatedRisks()
117
        {
2✔
118
            return eliminatedRisks;
2✔
119
        }
2✔
120

121
        public IEnumerable<EliminatedDocContentItem> GetEliminatedDocContents()
122
        {
2✔
123
            return eliminatedDocContents;
2✔
124
        }
2✔
125

126
        public IEnumerable<EliminatedAnomalyItem> GetEliminatedAnomalies()
127
        {
4✔
128
            return eliminatedAnomalies;
4✔
129
        }
4✔
130

131
        public IEnumerable<EliminatedSOUPItem> GetEliminatedSOUP()
132
        {
2✔
133
            return eliminatedSOUP;
2✔
134
        }
2✔
135

136
        protected void ClearAllItems()
137
        {
4✔
138
            systemRequirements.Clear();
4✔
139
            softwareRequirements.Clear();
4✔
140
            documentationRequirements.Clear();
4✔
141
            testCases.Clear();
4✔
142
            anomalies.Clear();
4✔
143
            risks.Clear();
4✔
144
            soup.Clear();
4✔
145
            docContents.Clear();
4✔
146
            unitTests.Clear();
4✔
147
            dependencies.Clear();
4✔
148
            testResults.Clear();
4✔
149
            eliminatedSystemRequirements.Clear();
4✔
150
            eliminatedSoftwareRequirements.Clear();
4✔
151
            eliminatedDocumentationRequirements.Clear();
4✔
152
            eliminatedSoftwareSystemTests.Clear();
4✔
153
            eliminatedSOUP.Clear();
4✔
154
            eliminatedRisks.Clear();
4✔
155
            eliminatedDocContents.Clear();
4✔
156
            eliminatedAnomalies.Clear();
4✔
157
        }
4✔
158

159
        protected string EscapeNonTablePipes(string text)
160
        {
84✔
161
            string tableBlockPattern = @"(?ms)(^\|===\s*$.*?^\|===\s*$)";
84✔
162

163
            // Use Regex.Split with a capturing group so that the table blocks are kept in the result.
164
            string[] segments = Regex.Split(text, tableBlockPattern);
84✔
165
            var sb = new StringBuilder();
84✔
166

167
            foreach (string segment in segments)
436✔
168
            {
92✔
169
                // If the segment itself matches our table block pattern, leave it unmodified.
170
                if (Regex.IsMatch(segment, @"(?ms)^\|===\s*$.*?^\|===\s*$"))
92✔
171
                {
4✔
172
                    sb.Append(segment);
4✔
173
                }
4✔
174
                else
175
                {
88✔
176
                    // Otherwise, escape any unescaped "|" in this segment.
177
                    string processed = Regex.Replace(segment, @"(?<!\\)\|", @"\|");
88✔
178
                    sb.Append(processed);
88✔
179
                }
88✔
180
            }
92✔
181
            return sb.ToString();
84✔
182
        }
84✔
183

184
        private void ScrubItemsFields<T>(IEnumerable<T> items)
185
        {
21✔
186
            foreach (var obj in items)
79✔
187
            {
8✔
188
                Type type = obj.GetType();
8✔
189
                PropertyInfo[] properties = type.GetProperties();
8✔
190

191
                foreach (PropertyInfo property in properties)
280✔
192
                {
128✔
193
                    if (property.PropertyType == typeof(string) && property.CanWrite)
128✔
194
                    {
78✔
195
                        string currentValue = (string)property.GetValue(obj);
78✔
196
                        if (currentValue != null)
78✔
197
                        {
78✔
198
                            // Escape pipes in non-table parts of the content.
199
                            string newValue = EscapeNonTablePipes(currentValue);
78✔
200
                            property.SetValue(obj, newValue);
78✔
201
                        }
78✔
202
                    }
78✔
203
                }
128✔
204
            }
8✔
205
        }
21✔
206

207
        // with the exception of docContent items, all other items are visualized
208
        // in tables and they need to escape the | character
209
        protected void ScrubItemContents()
210
        {
2✔
211
            ScrubItemsFields(systemRequirements);
2✔
212
            ScrubItemsFields(softwareRequirements);
2✔
213
            ScrubItemsFields(documentationRequirements);
2✔
214
            ScrubItemsFields(testCases);
2✔
215
            foreach (var testCase in testCases)
8✔
216
            {
1✔
217
                ScrubItemsFields(testCase.TestCaseSteps);
1✔
218
            }
1✔
219
            ScrubItemsFields(anomalies);
2✔
220
            ScrubItemsFields(risks);
2✔
221
            ScrubItemsFields(soup);
2✔
222
            ScrubItemsFields(unitTests);
2✔
223
            ScrubItemsFields(dependencies);
2✔
224
            ScrubItemsFields(testResults);
2✔
225
        }
2✔
226
    }
227
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc