Function $translate
has 917 lines of code (exceeds 25 allowed). Consider refactoring. Open
function $translate($STORAGE_KEY, $windowProvider, $translateSanitizationProvider, pascalprechtTranslateOverrider) {
'use strict';
var $translationTable = {},
File angular-translate.js
has 1340 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* angular-translate - v2.7.2 - 2015-06-01
* http://github.com/angular-translate/angular-translate
* Copyright (c) 2015 ; Licensed MIT
*/
Function $get
has 545 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ($log, $injector, $rootScope, $q) {
var Storage,
defaultInterpolator = $injector.get($interpolationFactory || '$translateDefaultInterpolation'),
pendingLoader = false,
Function translateDirective
has 169 lines of code (exceeds 25 allowed). Consider refactoring. Open
function translateDirective($translate, $q, $interpolate, $compile, $parse, $rootScope) {
'use strict';
/**
Function compile
has 159 lines of code (exceeds 25 allowed). Consider refactoring. Open
compile: function (tElement, tAttr) {
var translateValuesExist = (tAttr.translateValues) ?
tAttr.translateValues : undefined;
Function linkFn
has 150 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function linkFn(scope, iElement, iAttr) {
scope.interpolateParams = {};
scope.preText = '';
scope.postText = '';
Function $translateSanitizationProvider
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
function $translateSanitizationProvider () {
'use strict';
var $sanitize,
Function $translate
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
var $translate = function (translationId, interpolateParams, interpolationId, defaultTranslationText) {
// Duck detection: If the first argument is an array, a bunch of translations was requested.
// The result is an object.
if (angular.isArray(translationId)) {
Function refresh
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
$translate.refresh = function (langKey) {
if (!$loaderFactory) {
throw new Error('Couldn\'t refresh translation table, no loader registered!');
}
Function instant
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
$translate.instant = function (translationId, interpolateParams, interpolationId) {
// Detect undefined and null values to shorten the execution and prevent exceptions
if (translationId === null || angular.isUndefined(translationId)) {
return translationId;
Function loadAsync
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
var loadAsync = function (key) {
if (!key) {
throw 'No language key specified for loading.';
}
Function $get
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.$get = ['$injector', '$log', function ($injector, $log) {
var applyStrategies = function (value, mode, selectedStrategies) {
angular.forEach(selectedStrategies, function (selectedStrategy) {
if (angular.isFunction(selectedStrategy)) {
Function use
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
$translate.use = function (key) {
if (!key) {
return $uses;
}
Function determineTranslation
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
var determineTranslation = function (translationId, interpolateParams, interpolationId, defaultTranslationText) {
var deferred = $q.defer();
var table = $uses ? $translationTable[$uses] : $translationTable,
Function negotiateLocale
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
var negotiateLocale = function (preferred) {
var avail = [],
locale = angular.lowercase(preferred),
i = 0,
Function determineTranslationInstant
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
var determineTranslationInstant = function (translationId, interpolateParams, interpolationId) {
var result, table = $uses ? $translationTable[$uses] : $translationTable,
Interpolator = defaultInterpolator;
Function translateDirective
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function translateDirective($translate, $q, $interpolate, $compile, $parse, $rootScope) {
Avoid deeply nested control flow statements. Open
if (!langPromises[$fallbackLanguage[i]]) {
langPromises[$fallbackLanguage[i]] = loadAsync($fallbackLanguage[i]);
}
Function resolveForFallbackLanguage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var resolveForFallbackLanguage = function (fallbackLanguageIndex, translationId, interpolateParams, Interpolator, defaultTranslationText) {
Function updateTranslation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
var updateTranslation = function(translateAttr, translationId, scope, interpolateParams, defaultTranslationText) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
bcp47: function (tag) {
var temp = (tag || '').split('_').join('-');
var parts = temp.split('-');
return parts.length > 1 ? (parts[0].toLowerCase() + '-' + parts[1].toUpperCase()) : temp;
}
- 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 100.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
java: function (tag) {
var temp = (tag || '').split('-').join('_');
var parts = temp.split('_');
return parts.length > 1 ? (parts[0].toLowerCase() + '_' + parts[1].toUpperCase()) : temp;
},
- 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 100.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
this.statefulFilter = function (state) {
if (state === undefined) {
// getter
return statefulFilter;
} else {
- 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 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
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
this.directivePriority = function (priority) {
if (priority === undefined) {
// getter
return directivePriority;
} else {
- 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 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
- 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