guavacat/minitranslate

View on GitHub
js/minitranslate.js

Summary

Maintainability
A
1 hr
Test Coverage

Function mt_watch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function mt_watch(mt_lib) {
  var inp = document.getElementById("mt-input");
  var outp = document.getElementById("mt-output");
  var butt = document.getElementById("mt-button");
  if (inp !== null && outp !== null) {
Severity: Minor
Found in js/minitranslate.js - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function mt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function mt(mt_lib, div) {
  if ((div.innerHTML !== '' || div.value !== '') && (mt_lib.length > 0 && div.getAttribute("class") !== "mt-ignore")) {
    if (div.children.length > 0) {
      Array.prototype.forEach.call(div.children, function(el) {
        if (el.getAttribute("class") !== "mt-ignore") {
Severity: Minor
Found in js/minitranslate.js - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function apply_capitals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function apply_capitals(word, capitals) {
  var ret = "";
  var end = (word.length >= capitals.length) ? capitals.length : word.length;
  for (var i = 0; i < end; i++) {
    if (capitals[i]) {
Severity: Minor
Found in js/minitranslate.js - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

There are no issues that match your filters.

Category
Status