navchandar/Show-Price-as-Hours

View on GitHub
ShowPrice.user.js

Summary

Maintainability
A
0 mins
Test Coverage

Function updateValuesINR has a Cognitive Complexity of 102 (exceeds 5 allowed). Consider refactoring.
Wontfix

function updateValuesINR() {
  var approxHourlySalary = Number(GM_getValue("approxAnnualSalary", "")) / (9 * 22 * 12);
  if (!approxHourlySalary) {
    console.log("Error calculating approxHourlySalary.")
  }
Severity: Minor
Found in ShowPrice.user.js - About 2 days 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 updateValuesINR has 152 lines of code (exceeds 25 allowed). Consider refactoring.
Invalid

function updateValuesINR() {
  var approxHourlySalary = Number(GM_getValue("approxAnnualSalary", "")) / (9 * 22 * 12);
  if (!approxHourlySalary) {
    console.log("Error calculating approxHourlySalary.")
  }
Severity: Major
Found in ShowPrice.user.js - About 6 hrs to fix

    Avoid deeply nested control flow statements.
    Wontfix

                if (has(txt, 'Buy')) {
                  txt = txt.split('Buy')[0];
                }
    Severity: Major
    Found in ShowPrice.user.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Wontfix

                  if (amount > 0) {
                    var calculated = (amount / approxHourlySalary);
                    if (calculated) {
                      if (calculated <= 10) {
                        appender = (separator + "<b>(" + (calculated).toFixed(1).toString() + " hrs)</b>");
      Severity: Major
      Found in ShowPrice.user.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Wontfix

                    if (has(txt, '-')) {
                      txt = txt.split('-')[1];
                    }
        Severity: Major
        Found in ShowPrice.user.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Wontfix

                      if (has(txt, '+')) {
                        txt = txt.split('+')[0];
                      }
          Severity: Major
          Found in ShowPrice.user.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Wontfix

                        if (has(txt, 'to')) {
                          txt = txt.split('to')[1];
                        }
            Severity: Major
            Found in ShowPrice.user.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Wontfix

                          if (has(txt, '%') && has(txt, '-')) {
                            txt = txt.split('-')[0]
                          }
              Severity: Major
              Found in ShowPrice.user.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Wontfix

                            if (!amount || amount <= 0) {
                              amount = Number(((txt.replace(".00", "").replace(/\.\d+/, "")).replace(/\.\d+\./, "")).replace(/\D+/g, ""));
                            }
                Severity: Major
                Found in ShowPrice.user.js - About 45 mins to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Invalid

                          try {
                            if (has(txt, 'hrs') | has(txt, 'Day') | has(txt, 'Month') | has(txt, 'YEARS')) {
                              alreadyUpdated = true;
                            }
                          }
                  Severity: Major
                  Found in ShowPrice.user.js and 1 other location - About 1 hr to fix
                  ShowPrice.user.js on lines 155..160

                  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 60.

                  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

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Invalid

                          try {
                            if (has(htm, 'hrs') | has(htm, 'Day') | has(htm, 'Month') | has(htm, 'YEARS')) {
                              alreadyUpdated = true;
                            }
                          }
                  Severity: Major
                  Found in ShowPrice.user.js and 1 other location - About 1 hr to fix
                  ShowPrice.user.js on lines 149..154

                  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 60.

                  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

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Invalid

                      var amazonINRxpath = "//span[contains(@class, 'CurrencyINR')]//following-sibling::span" + " | " +
                        "//span[@class='currencyINR']/parent::*" + " | " +
                        "//*[contains(@class, 'rice')][contains(text(), '₹')]" + " | " +
                        "//*[contains(@class, 'price')]//*[contains(text(), '₹')]" + " | " +
                        "//*[contains(@class, 'price-whole')]" + " | " +
                  Severity: Major
                  Found in ShowPrice.user.js and 1 other location - About 1 hr to fix
                  ShowPrice.user.js on lines 67..74

                  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 57.

                  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

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Invalid

                      var amazonUSDxpath = "//*[@class='dealPrice']" + " | " +
                        "//*[@class='buyingPrice']" + " | " +
                        "//*[contains(@class,'-price-whole')]" + " | " +
                        "(//span[@class='dv-conditional-linebreak']//following-sibling::text())[1]" + " | " +
                        "(//span[@class='dv-conditional-linebreak']//following-sibling::text())[2]" + " | " +
                  Severity: Major
                  Found in ShowPrice.user.js and 1 other location - About 1 hr to fix
                  ShowPrice.user.js on lines 58..65

                  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 57.

                  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

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Invalid

                                  else if (calculated < 190) {
                                    appender = (separator + "<b>(" + (calculated / 9).toFixed(1).toString() + " Days)</b>");
                                    thisitem.innerHTML += appender;
                                  }
                                  else if (calculated < 2380) {
                  Severity: Minor
                  Found in ShowPrice.user.js and 1 other location - About 55 mins to fix
                  ShowPrice.user.js on lines 206..213

                  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 53.

                  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

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Invalid

                                  else if (calculated < 2380) {
                                    appender = (separator + "<b>(" + (calculated / 198).toFixed(1).toString() + " Months)</b>");
                                    thisitem.innerHTML += appender;
                                  }
                                  else {
                  Severity: Minor
                  Found in ShowPrice.user.js and 1 other location - About 55 mins to fix
                  ShowPrice.user.js on lines 202..213

                  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 53.

                  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

                  Further Reading

                  There are no issues that match your filters.

                  Category
                  Status