src/backgrid_modules/formatters/cell.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 58
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
c 2
b 0
f 0
nc 1
dl 0
loc 58
rs 10
wmc 3
mnd 0
bc 3
fnc 3
bpm 1
cpm 1
noi 3

3 Functions

Rating   Name   Duplication   Size   Complexity  
A cell.js ➔ CellFormatter 0 1 1
A _.extend.toRaw 0 3 1
A _.extend.fromRaw 0 3 1
1
import _ from 'underscore';
0 ignored issues
show
introduced by
Definition for rule 'keyword-spacing' was not found
Loading history...
2
/*
3
  backgrid
4
  http://github.com/wyuenho/backgrid
5
6
  Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors
7
  Licensed under the MIT license.
8
*/
9
10
/**
11
   Just a convenient class for interested parties to subclass.
12
13
   The default Cell classes don't require the formatter to be a subclass of
14
   Formatter as long as the fromRaw(rawData) and toRaw(formattedData) methods
15
   are defined.
16
17
   @abstract
18
   @class Backgrid.CellFormatter
19
   @constructor
20
*/
21
var CellFormatter = function () {};
22
_.extend(CellFormatter.prototype, {
23
24
  /**
25
     Takes a raw value from a model and returns an optionally formatted string
26
     for display. The default implementation simply returns the supplied value
27
     as is without any type conversion.
28
29
     @member Backgrid.CellFormatter
30
     @param {*} rawData
31
     @param {Backbone.Model} model Used for more complicated formatting
32
     @return {*}
33
  */
34
  fromRaw: function (rawData, model) {
0 ignored issues
show
Unused Code introduced by
The parameter model is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
35
    return rawData;
36
  },
37
38
  /**
39
     Takes a formatted string, usually from user input, and returns a
40
     appropriately typed value for persistence in the model.
41
42
     If the user input is invalid or unable to be converted to a raw value
43
     suitable for persistence in the model, toRaw must return `undefined`.
44
45
     @member Backgrid.CellFormatter
46
     @param {string} formattedData
47
     @param {Backbone.Model} model Used for more complicated formatting
48
     @return {*|undefined}
49
  */
50
  toRaw: function (formattedData, model) {
0 ignored issues
show
Unused Code introduced by
The parameter model is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
51
    return formattedData;
52
  }
53
54
});
55
56
export {
57
  CellFormatter
58
};
59