shaungrady/angular-http-etag

View on GitHub
lib/index.js

Summary

Maintainability
F
1 mo
Test Coverage

File index.js has 462 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * angular-http-etag v2.0.18
 * Shaun Grady (http://shaungrady.com), 2018
 * https://github.com/shaungrady/angular-http-etag
 * Module Format: CommonJS
Severity: Minor
Found in lib/index.js - About 7 hrs to fix

    Function service_httpEtagProvider has 163 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function service_httpEtagProvider () {
      var httpEtagProvider = this
    
      var serviceAdapterMethods = [
        'createCache',
    Severity: Major
    Found in lib/index.js - About 6 hrs to fix

      Function httpEtagHttpDecorator has 152 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function httpEtagHttpDecorator ($delegate, httpEtag) {
        var $http = $delegate
        var cachableHttpMethods = [
          'GET',
          'JSONP'
      Severity: Major
      Found in lib/index.js - About 6 hrs to fix

        Function httpEtagFactory has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          httpEtagProvider.$get = ['$injector', function httpEtagFactory ($injector) {
            var httpEtagService = {}
        
            var services = {}
            var adaptedServices = {}
        Severity: Major
        Found in lib/index.js - About 4 hrs to fix

          Function cacheAdaptersConfig has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function cacheAdaptersConfig (httpEtagProvider) {
            httpEtagProvider
          
              .defineCacheServiceAdapter('$cacheFactory', {
                config: {
          Severity: Major
          Found in lib/index.js - About 3 hrs to fix

            Function $httpDecorator has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function $httpDecorator (httpConfig) {
                var useLegacyPromiseExtensions = httpEtagHttpDecorator.useLegacyPromiseExtensions()
                var hasConfig = !!httpConfig.etagCache
                var isCacheableMethod = cachableHttpMethods.indexOf(httpConfig.method) >= 0
                var isCachable = hasConfig && isCacheableMethod
            Severity: Major
            Found in lib/index.js - About 2 hrs to fix

              Function exports has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

              /******/ (function(modules) { // webpackBootstrap
              /******/     // The module cache
              /******/     var installedModules = {};
              /******/
              /******/     // The require function
              Severity: Minor
              Found in lib/index.js - About 2 hrs 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 adaptCache has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  external_angular_default.a.forEach(cacheDefinitions, function adaptCache (config, cacheId) {
                    adaptedServices[config.cacheService].createCache(cacheId, config)
                    var cache = caches[cacheId] = adaptedServices[config.cacheService].getCache(cacheId)
                    var adaptedCache = adaptedCaches[cacheId] = {}
                    // Determine whether to perform deepcopying or not
              Severity: Major
              Found in lib/index.js - About 2 hrs to fix

                Function httpEtagPromiseFactory has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function httpEtagPromiseFactory (httpPromise) {
                      var then = httpPromise.then
                      var success = httpPromise.success
                
                      if (useLegacyPromiseExtensions) {
                Severity: Minor
                Found in lib/index.js - About 1 hr to fix

                  Function processHttpConfigEtagValue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function processHttpConfigEtagValue (httpConfig) {
                      var etagValue = httpConfig.etagCache
                      var etagValueType = typeof etagValue
                      var etagCacheConfig = {}
                  
                  
                  Severity: Minor
                  Found in lib/index.js - About 1 hr to fix

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

                    function httpEtagHttpDecorator ($delegate, httpEtag) {
                      var $http = $delegate
                      var cachableHttpMethods = [
                        'GET',
                        'JSONP'
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 1 wk to fix
                    release/angular-http-etag.js on lines 1504..1701

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

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

                    /******/ (function(modules) { // webpackBootstrap
                    /******/     // The module cache
                    /******/     var installedModules = {};
                    /******/
                    /******/     // The require function
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 5 days to fix
                    release/angular-http-etag.js on lines 19..1868

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

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                    function cacheAdaptersConfig (httpEtagProvider) {
                      httpEtagProvider
                    
                        .defineCacheServiceAdapter('$cacheFactory', {
                          config: {
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 4 days to fix
                    release/angular-http-etag.js on lines 1740..1842

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

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

                          external_angular_default.a.forEach(cacheAdapterMethods, function (method) {
                            var adapterMethod = cacheAdapters[config.cacheService].methods[method]
                            var wrappedMethod
                            var wrappedRawMethod
                    
                    
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 2 days to fix
                    release/angular-http-etag.js on lines 1373..1413

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

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                        httpEtagService.getItemCache = function httpEtagServiceGeItemCache (cacheId, itemKey) {
                          var cache = httpEtagService.getCache(cacheId)
                          var itemCache = {}
                          if (!cache) return
                    
                    
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 1 day to fix
                    release/angular-http-etag.js on lines 1441..1469

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

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

                    /* harmony default export */ var src = __webpack_exports__["default"] = (external_angular_default.a
                      .module('http-etag', [])
                      .provider('httpEtag', src_service)
                      .config(cacheServiceAdapters)
                      .config(['$provide', '$httpProvider', function addHttpEtagInterceptor ($provide, $httpProvider) {
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 6 hrs to fix
                    release/angular-http-etag.js on lines 1851..1864

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

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                    function httpEtagInterceptorFactory () {
                      function responseInterceptor (response) {
                        var itemCache = response.config.$$_itemCache
                    
                        if (itemCache) {
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 6 hrs to fix
                    release/angular-http-etag.js on lines 1706..1731

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

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                        external_angular_default.a.forEach(cacheAdapters, function adaptCacheService (adapter, serviceName) {
                          var service = services[serviceName] = window[serviceName] || $injector.get(serviceName)
                          var adaptedService = adaptedServices[serviceName] = {}
                    
                          external_angular_default.a.forEach(serviceAdapterMethods, function (method) {
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 4 hrs to fix
                    release/angular-http-etag.js on lines 1352..1359

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

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                      httpEtagProvider.defineCacheServiceAdapter = function httpEtagDefineCacheServiceAdapter (serviceName, config) {
                        if (!config) throw new Error('Missing cache service adapter configuration')
                        if (!config.methods) throw new Error('Missing cache service adapter configuration methods')
                        external_angular_default.a.forEach(requiredAdapterMethods, function (method) {
                          if (typeof config.methods[method] !== 'function') {
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 4 hrs to fix
                    release/angular-http-etag.js on lines 1316..1327

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

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                      httpEtagProvider.defineCache = function httpEtagDefineCache (cacheId, config) {
                        config = external_angular_default.a.extend({}, defaultEtagCacheConfig, config, { id: cacheId })
                        cacheDefinitions[cacheId] = config
                        return httpEtagProvider
                      }
                    Severity: Major
                    Found in lib/index.js and 1 other location - About 1 hr to fix
                    release/angular-http-etag.js on lines 1310..1314

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

                    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

                    Identical blocks of code found in 3 locations. Consider refactoring.
                    Open

                          adaptedCache.expireItem = function adaptedCacheUnsetItemCache (itemKey) {
                            var data = adaptedCache.$getItem(itemKey)
                            delete data.etagHeader
                            adaptedCache.$setItem(itemKey, data)
                          }
                    Severity: Major
                    Found in lib/index.js and 2 other locations - About 1 hr to fix
                    release/angular-http-etag.js on lines 1418..1422
                    src/service.js on lines 164..168

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

                    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 3 locations. Consider refactoring.
                    Open

                        function processCacheId (cacheId) {
                          var type = typeof cacheId
                          var isDefined = type === 'number' || (type === 'string' && !!cacheId)
                          return isDefined ? cacheId : defaultCacheId
                        }
                    Severity: Major
                    Found in lib/index.js and 2 other locations - About 55 mins to fix
                    release/angular-http-etag.js on lines 1477..1481
                    src/service.js on lines 223..227

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

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                        httpEtagService.purgeCaches = function httpEtagPurgeCaches () {
                          external_angular_default.a.forEach(adaptedCaches, function (cache) {
                            cache.removeAllItems()
                          })
                        }
                    Severity: Minor
                    Found in lib/index.js and 1 other location - About 45 mins to fix
                    release/angular-http-etag.js on lines 1471..1475

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

                    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