File pretty-print.js
has 683 lines of code (exceeds 250 allowed). Consider refactoring. Open
if (typeof prettyPrint === "undefined") {
// prettify.js
// http://code.google.com/p/google-code-prettify/
// prettier-ignore
window.PR_SHOULD_USE_CONTINUATION = true;
Function O
has 133 lines of code (exceeds 25 allowed). Consider refactoring. Open
function O(b) {
function f(c) {
if (c.charAt(0) !== "\\") return c.charCodeAt(0);
switch (c.charAt(1)) {
Consider simplifying this complex logical expression. Open
if (typeof prettyPrint === "undefined") {
// prettify.js
// http://code.google.com/p/google-code-prettify/
// prettier-ignore
window.PR_SHOULD_USE_CONTINUATION = true;
Function prettyPrint
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.prettyPrint = function (b) {
function f() {
for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
var p = o[q];
Function U
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
function U(b) {
var f = b.f,
i = b.e;
b.a = f;
Function $
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
function $(b) {
function f(D) {
if (D > r) {
if (j && j !== q) {
n.push("</span>");
Function B
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function B(b, f) {
var i = {},
o;
(function () {
Function f
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
function f() {
for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
var p = o[q];
if (p.className && p.className.indexOf("prettyprint") >= 0) {
Function o
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function o(c) {
var d = c.substring(1, c.length - 1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]", "g"));
c = [];
for (var a = [], k = d[0] === "^", e = k ? 1 : 0, h = d.length; e < h; ++e) {
Function n
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function n(r) {
for (var j = r.c, q = [j, z], m = 0, t = r.source.match(o) || [], p = {}, c = 0, d = t.length; c < d; ++c) {
var a = t[c],
k = p[a],
e = void 0,
Function H
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function H(b, f, i) {
switch (b.nodeType) {
case 1:
var o = b.tagName.toLowerCase();
f.push("<", o);
Function f
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function f(c) {
if (c.charAt(0) !== "\\") return c.charCodeAt(0);
switch (c.charAt(1)) {
case "b":
Function l
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function l(c) {
for (var d = c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g")), a = d.length, k = [], e = 0, h = 0; e < a; ++e) {
var g = d[e];
if (g === "(") ++h;else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) k[g] = -1;
}
Avoid deeply nested control flow statements. Open
for (var r = [], j = n; --j >= 0;) {
r[j] = l[j];
}
Avoid deeply nested control flow statements. Open
if (K) {
d = a.innerHTML;
if ("XMP" === a.tagName) d = y(d);else {
a = a;
if ("PRE" === a.tagName) a = true;else if (ka.test(d)) {
Avoid deeply nested control flow statements. Open
if (k < 0) a = p;else {
for (--k; (k = p.indexOf("&#", k + 1)) >= 0;) {
var e = p.indexOf(";", k);
if (e >= 0) {
Avoid deeply nested control flow statements. Open
if ((a.tagName === "pre" || a.tagName === "code" || a.tagName === "xmp") && a.className && a.className.indexOf("prettyprint") >= 0) {
d = true;
break;
}
Avoid deeply nested control flow statements. Open
if (!ba.test(m)) if (ca.test(m)) {
f.push(m.substring(9, m.length - 3));
n += m.length - 12;
} else if (da.test(m)) {
f.push("\n");
Avoid deeply nested control flow statements. Open
for (h = 0; h < l; ++h) {
g = f[h];
if (e = a.match(g[1])) {
k = g[0];
Avoid deeply nested control flow statements. Open
} else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) d[e] = "\\" + k[h];
Avoid deeply nested control flow statements. Open
if (null === K) {
d = document.createElement("PRE");
d.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
K = !/</.test(d.innerHTML);
}
Avoid deeply nested control flow statements. Open
if (p = m.a) {
c = m.b;
if ("XMP" === c.tagName) {
d = document.createElement("PRE");
Consider simplifying this complex logical expression. Open
if (!(s < 65 || g > 122)) {
s < 65 || g > 90 || a.push([Math.max(65, g) | 32, Math.min(s, 90) | 32]);
s < 97 || g > 122 || a.push([Math.max(97, g) & -33, Math.min(s, 122) & -33]);
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (typeof prettyPrint === "undefined") {
// prettify.js
// http://code.google.com/p/google-code-prettify/
// prettier-ignore
window.PR_SHOULD_USE_CONTINUATION = true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 8069.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76