Skip to content

Commit 9fc6438

Browse files
committed
Remove unused getSortKey from DataValue interface
I'm trying to minimize the unused code in this repository for years. Today I finally found a string I can pull without the whole thing breaking apart: Just do a fultext search for "getSortKey" and you will see it is not used anywhere. This will allow us to remove much, much more unused code. I'm focusing on two very small methods here and plan to continue removing more unused code in later patches. * The iso6709 method on the class is unused now. Note there is an other static helper function with the same name and a parameter. That is still used. * _getTimestamp is private anyway. The parameter is unused now.
1 parent 61706b5 commit 9fc6438

17 files changed

+30
-234
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ On [Packagist](https://packagist.org/packages/data-values/javascript):
1212
## Release notes
1313

1414
### 0.9.0 (dev)
15-
* Deprecated `dataValues.TimeValue.getYear`.
15+
16+
#### Breaking changes
1617
* Removed `dataValues.TimeValue.getMonth`, `getDay`, `getHour`, `getMinute`, and `getSecond`.
17-
* Made `globeCoordinate.GlobeCoordinate.getDecimal` private.
18+
* Removed `dataValues.DataValue.getSortKey` from the interface and all implementations.
19+
* Removed `globeCoordinate.GlobeCoordinate.iso6709`.
20+
* Declared `globeCoordinate.GlobeCoordinate.getDecimal` private.
21+
22+
#### Other changes
23+
* Deprecated `dataValues.TimeValue.getYear`.
1824

1925
### 0.8.4 (2017-07-18)
2026
* Updated JSDoc tags mistakenly requiring objects.

lib/globeCoordinate/globeCoordinate.GlobeCoordinate.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,6 @@
119119
};
120120
},
121121

122-
/**
123-
* Returns a coordinate's ISO 6709 string representation.
124-
* (see globeCoordinate.iso6709)
125-
*
126-
* @return {string}
127-
*/
128-
iso6709: function() {
129-
return globeCoordinate.iso6709( this.getDecimal() );
130-
},
131-
132122
/**
133123
* Compares the object to another GlobeCoordinate object and returns whether both represent
134124
* the same information.

src/DataValue.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ $.extend( SELF.prototype, {
3838
*/
3939
getValue: util.abstractMember,
4040

41-
/**
42-
* Returns a key that can be used for sorting the data value.
43-
* Can be either numeric or a string.
44-
* NOTE: this could very well be set by the API, together with the value. Since the value is
45-
* immutable, this won't change as well and there is no need for having the logic here.
46-
* @abstract
47-
*
48-
* @return {string|number}
49-
*/
50-
getSortKey: util.abstractMember,
51-
5241
/**
5342
* Returns a simple JSON structure representing this data value.
5443
* @abstract

src/values/BoolValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ var SELF = dv.BoolValue = util.inherit( 'DvBoolValue', PARENT, function( value )
2929
*/
3030
_value: null,
3131

32-
/**
33-
* @inheritdoc
34-
*
35-
* @return {number}
36-
*/
37-
getSortKey: function() {
38-
return this._value ? 1 : 0;
39-
},
40-
4132
/**
4233
* @inheritdoc
4334
*

src/values/DecimalValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,6 @@ var SELF = dv.DecimalValue = util.inherit( 'DvDecimalValue', PARENT, function( v
119119
*/
120120
_value: null,
121121

122-
/**
123-
* @inheritdoc
124-
*
125-
* @return {string}
126-
*/
127-
getSortKey: function() {
128-
return this._value;
129-
},
130-
131122
/**
132123
* @inheritdoc
133124
*

src/values/GlobeCoordinateValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ var SELF
3434
*/
3535
_value: null,
3636

37-
/**
38-
* @inheritdoc
39-
*
40-
* @return {string}
41-
*/
42-
getSortKey: function() {
43-
return this.getValue().iso6709();
44-
},
45-
4637
/**
4738
* @inheritdoc
4839
*

src/values/MonolingualTextValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ var SELF
3838
*/
3939
_text: null,
4040

41-
/**
42-
* @inheritdoc
43-
*
44-
* @return string
45-
*/
46-
getSortKey: function() {
47-
return this._languageCode + this._text;
48-
},
49-
5041
/**
5142
* @inheritdoc
5243
*

src/values/MultilingualTextValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ var SELF
3030
*/
3131
_texts: null,
3232

33-
/**
34-
* @inheritdoc
35-
*
36-
* @return {string}
37-
*/
38-
getSortKey: function() {
39-
return this._texts.length < 1 ? '' : this._texts[0].getSortKey();
40-
},
41-
4233
/**
4334
* @inheritdoc
4435
*

src/values/NumberValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ var SELF = dv.NumberValue = util.inherit( 'DvNumberValue', PARENT, function( val
2525
*/
2626
_value: null,
2727

28-
/**
29-
* @inheritdoc
30-
*
31-
* @return {number}
32-
*/
33-
getSortKey: function() {
34-
return this._value;
35-
},
36-
3728
/**
3829
* @inheritdoc
3930
*

src/values/QuantityValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@ var SELF
7171
*/
7272
_upperBound: null,
7373

74-
/**
75-
* @inheritdoc
76-
*
77-
* @return {string}
78-
*/
79-
getSortKey: function() {
80-
return this._amount.getValue();
81-
},
82-
8374
/**
8475
* @inheritdoc
8576
*

src/values/StringValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ var SELF = dv.StringValue = util.inherit( 'DvStringValue', PARENT, function( val
3030
*/
3131
_value: null,
3232

33-
/**
34-
* @inheritdoc
35-
*
36-
* @return {string}
37-
*/
38-
getSortKey: function() {
39-
return this._value;
40-
},
41-
4233
/**
4334
* @inheritdoc
4435
*

src/values/TimeValue.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,6 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( timesta
130130
return this._options[key];
131131
},
132132

133-
/**
134-
* @inheritdoc
135-
*
136-
* @return {string}
137-
*/
138-
getSortKey: function() {
139-
return this.timestamp.replace( /^([+-])(\d+)/, function ( $0, sign, year ) {
140-
return sign + pad( year, 16 );
141-
} );
142-
},
143-
144133
/**
145134
* @inheritdoc
146135
*

src/values/UnDeserializableValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ var SELF = dv.UnDeserializableValue = util.inherit(
5757
*/
5858
_deserializeError: null,
5959

60-
/**
61-
* @inheritdoc
62-
*
63-
* @return {string}
64-
*/
65-
getSortKey: function() {
66-
return this.getReason();
67-
},
68-
6960
/**
7061
* @inheritdoc
7162
*

src/values/UnknownValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ var SELF = dv.UnknownValue = util.inherit( 'DvUnknownValue', PARENT, function( v
2424
*/
2525
_value: null,
2626

27-
/**
28-
* @inheritdoc
29-
*
30-
* @return {number}
31-
*/
32-
getSortKey: function() {
33-
return 0;
34-
},
35-
3627
/**
3728
* @inheritdoc
3829
*

tests/lib/globeCoordinate/globeCoordinate.GlobeCoordinate.tests.js

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ define( [
1414
QUnit.module( 'globeCoordinate.GlobeCoordinate.js' );
1515

1616
QUnit.test( 'Basic checks', function( assert ) {
17-
assert.expect( 10 );
17+
assert.expect( 9 );
1818
var c;
1919

2020
assert['throws'](
@@ -70,12 +70,6 @@ define( [
7070
{ latitude: 1.5, longitude: 1.5, precision: 0.1 },
7171
'Verified getDecimal()'
7272
);
73-
74-
assert.equal(
75-
typeof c.iso6709(),
76-
'string',
77-
'Verified iso6709()'
78-
);
7973
} );
8074

8175
QUnit.test( 'Precision defaults to null', function( assert ) {
@@ -119,36 +113,6 @@ define( [
119113
);
120114
} );
121115

122-
QUnit.test( 'ISO 6709 strings', function( assert ) {
123-
assert.expect( 12 );
124-
var gcDefs = [
125-
{ precision: 10, expected: '+10+010/' },
126-
{ precision: 2, expected: '+14+012/' },
127-
{ precision: 1, expected: '+13+012/' },
128-
{ precision: 0.1, expected: '+1307+01207/' },
129-
{ precision: 0.01, expected: '+130724+0120724/' },
130-
{ precision: 1 / 60, expected: '+1307+01207/' },
131-
{ precision: 1 / 3600, expected: '+130724+0120724/' },
132-
{ precision: 1 / 36000, expected: '+130724.4+0120724.4/' },
133-
{ precision: 1 / 360000, expected: '+130724.42+0120724.42/' },
134-
{ precision: 0, expected: '+130724.42+0120724.42/' },
135-
{ precision: null, expected: '+130724.42+0120724.42/' },
136-
{ expected: '+130724.42+0120724.42/' }
137-
],
138-
c;
139-
140-
$.each( gcDefs, function( i, gcDef ) {
141-
c = new globeCoordinate.GlobeCoordinate(
142-
{ latitude: 13.12345, longitude: 12.12345, precision: gcDef.precision }
143-
);
144-
145-
assert.ok(
146-
c.iso6709() === gcDef.expected,
147-
'Validated ISO 6709 string of data set #' + i + '.'
148-
);
149-
} );
150-
} );
151-
152116
QUnit.test( 'Strict (in)equality', function( assert ) {
153117
assert.expect( 169 );
154118
var gcDefs = [

tests/src/dataValues.DataValue.tests.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,6 @@ define( [
131131
}
132132
},
133133

134-
/**
135-
* Tests the getSortKey method.
136-
*
137-
* @since 0.1
138-
*
139-
* @param {QUnit.assert} assert
140-
*/
141-
testGetSortKey: function( assert ) {
142-
var instances = this.getInstances(),
143-
i,
144-
keyType;
145-
146-
for ( i in instances ) {
147-
keyType = typeof instances[i].getSortKey();
148-
149-
assert.ok(
150-
keyType === 'string' || keyType === 'number',
151-
'return value is a string or number'
152-
);
153-
}
154-
},
155-
156134
/**
157135
* Tests whether the data value's constructor has a newFromJSON function.
158136
*

0 commit comments

Comments
 (0)