Skip to content

Commit 101f766

Browse files
committed
fix codeclimate complexity + (exclude 96 ascii)
1 parent cb5e0d9 commit 101f766

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/lexer/utils.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ module.exports = {
3535
// check if current char can be a label
3636
is_LABEL_START: function() {
3737
const ch = this._input.charCodeAt(this.offset - 1);
38-
return (
39-
(ch > 96 && ch < 123) || (ch > 64 && ch < 91) || ch === 95 || ch > 126
40-
);
38+
// A - Z
39+
if (ch > 64 && ch < 91) return true;
40+
// a - z
41+
if (ch > 96 && ch < 123) return true;
42+
// _ (95)
43+
if (ch === 95) return true;
44+
// utf8 / extended
45+
if (ch > 126) return true;
46+
// else
47+
return false;
4148
},
4249

4350
// reads each char of the label
@@ -81,11 +88,15 @@ module.exports = {
8188
// check if current char can be a hexadecimal number
8289
is_HEX: function() {
8390
const ch = this._input.charCodeAt(this.offset - 1);
84-
return (
85-
(ch > 47 && ch < 58) ||
86-
(ch > 64 && ch < 71) ||
87-
(ch > 96 && ch < 103) ||
88-
ch === 95
89-
);
91+
// 0 - 9
92+
if (ch > 47 && ch < 58) return true;
93+
// A - F
94+
if (ch > 64 && ch < 71) return true;
95+
// a - f
96+
if (ch > 96 && ch < 103) return true;
97+
// _ (code 95)
98+
if (ch === 95) return true;
99+
// else
100+
return false;
90101
}
91102
};

0 commit comments

Comments
 (0)