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

MeindertN / RoboClerk / 13251903495

10 Feb 2025 10:41PM UTC coverage: 82.581% (-0.6%) from 83.163%
13251903495

push

github

MeindertN
WIP added the ability to convert textile format text as used in Redmine markup to ASCIIDOC. Also support nested tables in ItemTemplates through the EmbedAsciidocTables function which converts standard ASCIIDOC tables to nested table format.

1131 of 1352 branches covered (83.65%)

Branch coverage included in aggregate %.

15 of 51 new or added lines in 2 files covered. (29.41%)

1 existing line in 1 file now uncovered.

3610 of 4389 relevant lines covered (82.25%)

112.75 hits per line

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

13.28
/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>();
17✔
13
        protected List<RequirementItem> softwareRequirements = new List<RequirementItem>();
17✔
14
        protected List<RequirementItem> documentationRequirements = new List<RequirementItem>();
17✔
15
        protected List<SoftwareSystemTestItem> testCases = new List<SoftwareSystemTestItem>();
17✔
16
        protected List<AnomalyItem> anomalies = new List<AnomalyItem>();
17✔
17
        protected List<RiskItem> risks = new List<RiskItem>();
17✔
18
        protected List<SOUPItem> soup = new List<SOUPItem>();
17✔
19
        protected List<DocContentItem> docContents = new List<DocContentItem>();
17✔
20
        protected List<UnitTestItem> unitTests = new List<UnitTestItem>();
17✔
21
        protected List<ExternalDependency> dependencies = new List<ExternalDependency>();
17✔
22
        protected List<TestResult> testResults = new List<TestResult>();
17✔
23

24
        public DataSourcePluginBase(IFileSystem fileSystem)
25
            :base(fileSystem)
17✔
26
        {
17✔
27

28
        }
17✔
29

30
        public abstract void RefreshItems();
31

32
        public IEnumerable<AnomalyItem> GetAnomalies()
33
        {
×
34
            return anomalies;
×
35
        }
×
36

37
        public IEnumerable<RequirementItem> GetSystemRequirements()
38
        {
×
39
            return systemRequirements;
×
40
        }
×
41

42
        public IEnumerable<RequirementItem> GetSoftwareRequirements()
43
        {
×
44
            return softwareRequirements;
×
45
        }
×
46

47
        public IEnumerable<RequirementItem> GetDocumentationRequirements()
48
        {
×
49
            return documentationRequirements;
×
50
        }
×
51

52
        public IEnumerable<DocContentItem> GetDocContents()
53
        {
×
54
            return docContents;
×
55
        }
×
56

57
        public IEnumerable<SoftwareSystemTestItem> GetSoftwareSystemTests()
58
        {
×
59
            return testCases;
×
60
        }
×
61

62
        public IEnumerable<RiskItem> GetRisks()
63
        {
×
64
            return risks;
×
65
        }
×
66

67
        public IEnumerable<SOUPItem> GetSOUP()
68
        {
×
69
            return soup;
×
70
        }
×
71

72
        public IEnumerable<UnitTestItem> GetUnitTests()
73
        {
1✔
74
            return unitTests;
1✔
75
        }
1✔
76

77
        public IEnumerable<ExternalDependency> GetDependencies()
78
        {
×
79
            return dependencies;
×
80
        }
×
81

82
        public IEnumerable<TestResult> GetTestResults()
83
        {
×
84
            return testResults;
×
85
        }
×
86

87
        protected void ClearAllItems()
88
        {
×
89
            systemRequirements.Clear();
×
90
            softwareRequirements.Clear();
×
91
            documentationRequirements.Clear();
×
92
            testCases.Clear();
×
93
            anomalies.Clear();
×
94
            risks.Clear();
×
95
            soup.Clear();
×
96
            docContents.Clear();
×
97
            unitTests.Clear();
×
98
            dependencies.Clear();
×
99
            testResults.Clear();
×
100
        }
×
101

102
        private string EscapeNonTablePipes(string text)
NEW
103
        {
×
NEW
104
            string tableBlockPattern = @"(?ms)(^\|===\s*$.*?^\|===\s*$)";
×
105

106
            // Use Regex.Split with a capturing group so that the table blocks are kept in the result.
NEW
107
            string[] segments = Regex.Split(text, tableBlockPattern);
×
NEW
108
            var sb = new StringBuilder();
×
109

NEW
110
            foreach (string segment in segments)
×
NEW
111
            {
×
112
                // If the segment itself matches our table block pattern, leave it unmodified.
NEW
113
                if (Regex.IsMatch(segment, @"(?ms)^\|===\s*$.*?^\|===\s*$"))
×
NEW
114
                {
×
NEW
115
                    sb.Append(segment);
×
NEW
116
                }
×
117
                else
NEW
118
                {
×
119
                    // Otherwise, escape any unescaped "|" in this segment.
NEW
120
                    string processed = Regex.Replace(segment, @"(?<!\\)\|", @"\|");
×
NEW
121
                    sb.Append(processed);
×
NEW
122
                }
×
NEW
123
            }
×
NEW
124
            return sb.ToString();
×
NEW
125
        }
×
126

127
        private void ScrubItemsFields<T>(IEnumerable<T> items)
128
        {
×
129
            foreach (var obj in items)
×
130
            {
×
131
                Type type = obj.GetType();
×
132
                PropertyInfo[] properties = type.GetProperties();
×
133

134
                foreach (PropertyInfo property in properties)
×
135
                {
×
136
                    if (property.PropertyType == typeof(string) && property.CanWrite)
×
137
                    {
×
UNCOV
138
                        string currentValue = (string)property.GetValue(obj);
×
NEW
139
                        if (currentValue != null)
×
NEW
140
                        {
×
141
                            // Escape pipes in non-table parts of the content.
NEW
142
                            string newValue = EscapeNonTablePipes(currentValue);
×
NEW
143
                            property.SetValue(obj, newValue);
×
NEW
144
                        }
×
145
                    }
×
146
                }
×
147
            }
×
148
        }
×
149

150
        // with the exception of docContent items, all other items are visualized
151
        // in tables and they need to escape the | character
152
        protected void ScrubItemContents()
153
        {
×
154
            ScrubItemsFields(systemRequirements);
×
155
            ScrubItemsFields(softwareRequirements);
×
156
            ScrubItemsFields(documentationRequirements);
×
157
            ScrubItemsFields(testCases);
×
158
            foreach (var testCase in testCases)
×
159
            {
×
160
                ScrubItemsFields(testCase.TestCaseSteps);
×
161
            }
×
162
            ScrubItemsFields(anomalies);
×
163
            ScrubItemsFields(risks);
×
164
            ScrubItemsFields(soup);
×
165
            ScrubItemsFields(unitTests);
×
166
            ScrubItemsFields(dependencies);
×
167
            ScrubItemsFields(testResults);
×
168
        }
×
169
    }
170
}
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