Function init
has 549 lines of code (exceeds 25 allowed). Consider refactoring. Open
Configurer.init = function(object, config) {
object.configuration = config;
/**
* Those are HTTP safe methods for which there is no need to pass any data with the request.
File restangular.js
has 1044 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function() {
var restangular = angular.module('restangular', []);
restangular.provider('Restangular', function() {
Function $get
has 483 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.$get = ['$http', '$q', function($http, $q) {
function createServiceForConfiguration(config) {
var service = {};
Function createServiceForConfiguration
has 480 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createServiceForConfiguration(config) {
var service = {};
var urlHandler = new config.urlCreatorFactory[config.urlCreator]();
urlHandler.setConfig(config);
Function elemFunction
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
function elemFunction(operation, what, params, obj, headers) {
var __this = this;
var deferred = $q.defer();
var resParams = params || {};
var route = what || this[config.restangularFields.route];
Function fetchFunction
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetchFunction(what, reqParams, headers) {
var __this = this;
var deferred = $q.defer();
var operation = 'getList';
var url = urlHandler.fetchUrl(this, what);
Function resource
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
BaseCreator.prototype.resource = function(current, $http, localHttpConfig, callHeaders, callParams, what, etag,operation) {
var params = _.defaults(callParams || {}, this.config.defaultRequestParams.common);
var headers = _.defaults(callHeaders || {}, this.config.defaultHeaders);
Function okCallback
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
var okCallback = function(response) {
var resData = response.data;
var fullParams = response.config.params;
var data = parseResponse(resData, operation, whatFetched, url, response, deferred);
Function fetchRequestedUrl
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Path.prototype.fetchRequestedUrl = function(current, what) {
var url = this.fetchUrl(current, what);
var params = current[config.restangularFields.reqParams];
// From here on and until the end of fetchRequestedUrl,
Function restangularizeBase
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function restangularizeBase(parent, elem, route, reqParams, fromServer) {
elem[config.restangularFields.route] = route;
elem[config.restangularFields.getRestangularUrl] = _.bind(urlHandler.fetchUrl, urlHandler, elem);
elem[config.restangularFields.getRequestedUrl] = _.bind(urlHandler.fetchRequestedUrl, urlHandler, elem);
elem[config.restangularFields.addRestangularMethod] = _.bind(addRestangularMethodFunction, elem);
Function base
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Path.prototype.base = function(current) {
var __this = this;
return _.reduce(this.parentsArray(current), function(acum, elem) {
var elemUrl;
var elemSelfLink = __this.config.getUrlFromElem(elem);
Function okCallback
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
var okCallback = function(response) {
var resData = response.data;
var fullParams = response.config.params;
var elem = parseResponse(resData, operation, route, fetchUrl, response, deferred);
if (elem) {
Function resource
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
BaseCreator.prototype.resource = function(current, $http, localHttpConfig, callHeaders, callParams, what, etag,operation) {
Function fullRequestInterceptor
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
config.fullRequestInterceptor = function(element, operation, path, url, headers, params, httpConfig) {
Function defaultInterceptor
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
config.defaultInterceptor = function(element, operation, path, url, headers, params, httpConfig) {
Function parseResponse
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function parseResponse(resData, operation, route, fetchUrl, response, deferred) {
Function addRestangularMethodFunction
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function addRestangularMethodFunction(name, operation, path, defaultParams, defaultHeaders, defaultElem) {
Function responseExtractor
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
config.responseExtractor = function(data, operation, what, url, response, deferred) {
Function restangularizeElem
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function restangularizeElem(parent, element, route, fromServer, collection, reqParams) {
Function transformElem
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
config.transformElem = function(elem, isCollection, route, Restangular, force) {
Function customFunction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function customFunction(operation, path, params, headers, elem) {
Function elemFunction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function elemFunction(operation, what, params, obj, headers) {
Function restangularizeBase
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function restangularizeBase(parent, elem, route, reqParams, fromServer) {
Function restangularizeCollection
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function restangularizeCollection(parent, element, route, fromServer, reqParams) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
(function() {
var restangular = angular.module('restangular', []);
restangular.provider('Restangular', function() {
- 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 11532.
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