Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit 86fb8a9

Browse files
committed
linter fixes
1 parent 8d72272 commit 86fb8a9

11 files changed

+13
-67
lines changed

etld/matcher.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "etld/parser.h"
1010
#include "etld/public_suffix_rule.h"
1111
#include "etld/matcher.h"
12-
#include "etld/types.h"
1312
#include "etld/serialization.h"
1413

1514
namespace brave_etld {
@@ -53,8 +52,7 @@ SerializationResult Matcher::Serialize() const {
5352
buffer_size,
5453
"%s:%s",
5554
header_str.c_str(),
56-
buffer_body.c_str()
57-
);
55+
buffer_body.c_str());
5856

5957
SerializationResult info;
6058
info.body_start = body_start;

etld/matcher.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class Matcher {
2525
explicit Matcher(std::ifstream &rule_file);
2626
explicit Matcher(const std::string &rule_text);
2727
explicit Matcher(const PublicSuffixParseResult &rules);
28-
Matcher(const PublicSuffixRuleSet &rules, const PublicSuffixRuleSet &exception_rules);
28+
Matcher(const PublicSuffixRuleSet &rules,
29+
const PublicSuffixRuleSet &exception_rules);
2930

3031
SerializationResult Serialize() const;
3132

etld/parser.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* License, v. 2.0. If a copy of the MPL was not distributed with this
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
55

6-
#include <memory>
76
#include <string>
87
#include <sstream>
98
#include <fstream>
@@ -12,8 +11,6 @@
1211
#include "etld/public_suffix_rule.h"
1312
#include "etld/types.h"
1413

15-
using std::unique_ptr;
16-
1714
namespace brave_etld {
1815

1916
PublicSuffixParseResult::PublicSuffixParseResult() {}

etld/public_suffix_rule.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include "etld/types.h"
1414
#include "etld/serialization.h"
1515

16-
using std::unique_ptr;
17-
1816
namespace brave_etld {
1917

2018
std::vector<Label> parse_labels(const std::string &label_text) {
@@ -125,8 +123,7 @@ SerializationResult PublicSuffixRule::Serialize() const {
125123
header_str.c_str(),
126124
is_exception_ ? 't' : 'f',
127125
is_wildcard_ ? 't' : 'f',
128-
domain_string.c_str()
129-
);
126+
domain_string.c_str());
130127

131128
info.body_start = body_start;
132129
info.body_len = body_len;

etld/public_suffix_rule.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include "etld/types.h"
1313
#include "etld/serialization.h"
1414

15-
using std::unique_ptr;
16-
1715
namespace brave_etld {
1816

1917
class PublicSuffixRuleInputException : public std::exception {

etld/public_suffix_rule_set.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66
#include <string>
77
#include <sstream>
88
#include <vector>
9-
#include <memory>
109
#include <iostream>
1110
#include "etld/public_suffix_rule.h"
1211
#include "etld/public_suffix_rule_set.h"
1312
#include "etld/domain.h"
1413
#include "etld/types.h"
1514
#include "etld/serialization.h"
1615

17-
using std::unique_ptr;
18-
1916
namespace brave_etld {
2017

2118
PublicSuffixRuleSet::PublicSuffixRuleSet() {}
@@ -70,8 +67,7 @@ SerializationResult PublicSuffixRuleSet::Serialize() const {
7067
buffer_size,
7168
"%s:%s",
7269
header_str.c_str(),
73-
buffer_body.c_str()
74-
);
70+
buffer_body.c_str());
7571

7672
SerializationResult info;
7773
info.body_start = body_start;

etld/public_suffix_rule_set.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88

99
#include <string>
1010
#include <vector>
11-
#include <memory>
1211
#include "etld/public_suffix_rule.h"
1312
#include "etld/domain.h"
1413
#include "etld/types.h"
1514
#include "etld/serialization.h"
1615

17-
using std::unique_ptr;
18-
1916
namespace brave_etld {
2017

2118
struct PublicSuffixRuleSetMatchResult {

protocol.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool isBlockableProtocol(const char *url, int urlLen) {
4242

4343
const char *curChar = url;
4444
int totalCharsRead = 0;
45-
int numCharsReadInState;
45+
int numCharsReadInState = 0;
4646
char lowerChar;
4747
ProtocolParseState parseState = ProtocolParseStateStart;
4848

test/etld_serialization_test.cc

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -73,46 +73,6 @@ TEST(eTLDSerializationMatcher, basic) {
7373
CHECK(testSerializeMatcher("!one.com\n*.two.com\nthree.com"));
7474
}
7575

76-
bool testDeserializationCorrectness(const SerializedBuffer &rule_text,
77-
int num_rules, int num_exception_rules) {
78-
Matcher matcher = matcher_from_serialization(rule_text);
79-
int num_matcher_rules = static_cast<int>(matcher.NumRules());
80-
if (num_matcher_rules != num_rules) {
81-
std::cout << "Expected " << num_rules << " rules from buffer, but received "
82-
<< num_matcher_rules << " rules." << std::endl;
83-
return false;
84-
}
85-
86-
int num_matcher_except_rules = static_cast<int>(matcher.NumExceptionRules());
87-
if (num_matcher_except_rules != num_exception_rules) {
88-
std::cout << "Expected " << num_rules << " exception rules from buffer, "
89-
<< "but received " << num_exception_rules << " rules."
90-
<< std::endl;
91-
return false;
92-
}
93-
94-
return true;
95-
}
96-
97-
// TEST(eTLDDeserializationTests, basic) {
98-
// CHECK(testDeserializationCorrectness(
99-
// "47:42:29:ff||not-matching-anything.com8:fftrees^0:", 2, 0));
100-
// }
101-
102-
bool testSerializationCorrectness(const string &rule_text,
103-
const SerializedBuffer &serialized) {
104-
Matcher matcher(rule_text);
105-
SerializationResult result = matcher.Serialize();
106-
return result.buffer.compare(serialized) == 0;
107-
}
108-
109-
// TEST(eTLDSerializationTests, basic) {
110-
// const string rules = "||s3.amazonaws.com^$third-party\n"
111-
// "||not-matching-anything.com\n"
112-
// "trees^";
113-
// CHECK(testSerializationCorrectness(rules, ));
114-
// }
115-
11676
bool testMatcherSerializationTransitivity(const string &public_suffix_rules) {
11777
Matcher orig(public_suffix_rules);
11878
SerializationResult res = orig.Serialize();
@@ -135,7 +95,7 @@ bool testAdBlockClientSerializationTransitivity(const string &filter_rules,
13595
AdBlockClient client;
13696
client.parse(filter_rules.c_str());
13797
client.parsePublicSuffixRules(public_suffix_rules.c_str());
138-
98+
13999
int size;
140100
char* buffer = client.serialize(&size);
141101

@@ -167,4 +127,4 @@ TEST(eTLDSerializationTransitivity, basic) {
167127
CHECK(testMatcherSerializationTransitivity(public_suffix_rules));
168128
CHECK(testAdBlockClientSerializationTransitivity(
169129
filer_rules, public_suffix_rules));
170-
}
130+
}

test/etld_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,4 +543,4 @@ TEST(eTLDPublicSuffixRuleApplyFileTests, basic) {
543543
elm.input,
544544
elm.expected));
545545
}
546-
}
546+
}

0 commit comments

Comments
 (0)