Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
kresusapp
kresus
Commits
9c18b912
Commit
9c18b912
authored
Nov 05, 2017
by
Benjamin Bouvier
Browse files
Style: enforce curlies around control flow structures;
parent
129cc136
Pipeline
#28338
passed with stages
in 7 minutes and 50 seconds
Changes
39
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
.eslintrc.yml
View file @
9c18b912
...
...
@@ -89,7 +89,7 @@
consistent-return
:
-
0
curly
:
-
0
-
2
-
'
all'
default-case
:
-
2
...
...
client/components/categories/index.js
View file @
9c18b912
...
...
@@ -28,7 +28,9 @@ class CategoryList extends React.Component {
},
function
()
{
// then
if
(
this
.
state
.
showForm
)
this
.
newCategory
.
selectTitle
();
if
(
this
.
state
.
showForm
)
{
this
.
newCategory
.
selectTitle
();
}
}
);
}
...
...
client/components/charts/balance-chart.js
View file @
9c18b912
...
...
@@ -33,7 +33,9 @@ function createChartBalance(chartId, account, operations) {
// Date (day) -> cumulated sum of amounts for this day (scalar).
for
(
let
o
of
ops
)
{
let
key
=
makeKey
(
o
.
date
);
if
(
opmap
.
has
(
key
))
opmap
.
set
(
key
,
opmap
.
get
(
key
)
+
o
.
amount
);
if
(
opmap
.
has
(
key
))
{
opmap
.
set
(
key
,
opmap
.
get
(
key
)
+
o
.
amount
);
}
}
let
balance
=
account
.
initialAmount
;
...
...
client/components/charts/operations-by-category-chart.js
View file @
9c18b912
...
...
@@ -259,13 +259,21 @@ class OpCatChart extends ChartComponent {
}
handleShowAll
()
{
if
(
this
.
barchart
)
this
.
barchart
.
show
();
if
(
this
.
piechart
)
this
.
piechart
.
show
();
if
(
this
.
barchart
)
{
this
.
barchart
.
show
();
}
if
(
this
.
piechart
)
{
this
.
piechart
.
show
();
}
}
handleHideAll
()
{
if
(
this
.
barchart
)
this
.
barchart
.
hide
();
if
(
this
.
piechart
)
this
.
piechart
.
hide
();
if
(
this
.
barchart
)
{
this
.
barchart
.
hide
();
}
if
(
this
.
piechart
)
{
this
.
piechart
.
hide
();
}
}
render
()
{
...
...
client/components/duplicates/index.js
View file @
9c18b912
...
...
@@ -28,7 +28,9 @@ function findRedundantPairs(operations, duplicateThreshold) {
let
j
=
i
+
1
;
while
(
j
<
operations
.
length
)
{
let
next
=
sorted
[
j
];
if
(
next
.
amount
!==
op
.
amount
)
break
;
if
(
next
.
amount
!==
op
.
amount
)
{
break
;
}
// Two operations are duplicates if they were not imported at the same date.
let
datediff
=
Math
.
abs
(
+
op
.
date
-
+
next
.
date
);
...
...
client/components/menu/bank.js
View file @
9c18b912
...
...
@@ -101,7 +101,9 @@ const Export = connect((state, props) => {
total
+=
balance
;
accountsBalances
.
set
(
acc
.
id
,
balance
);
if
(
sameCurrency
)
sameCurrency
=
!
currency
||
currency
===
acc
.
currency
;
if
(
sameCurrency
)
{
sameCurrency
=
!
currency
||
currency
===
acc
.
currency
;
}
currency
=
currency
||
acc
.
currency
;
formatCurrency
=
formatCurrency
||
acc
.
formatCurrency
;
...
...
client/components/operations/index.js
View file @
9c18b912
...
...
@@ -232,7 +232,9 @@ function filter(operations, search) {
}
function
filterIf
(
condition
,
array
,
callback
)
{
if
(
condition
)
return
array
.
filter
(
callback
);
if
(
condition
)
{
return
array
.
filter
(
callback
);
}
return
array
;
}
...
...
client/components/operations/label.js
View file @
9c18b912
...
...
@@ -51,7 +51,9 @@ class LabelComponent_ extends React.Component {
}
handleBlur
()
{
if
(
this
.
state
.
editedValue
===
null
)
return
;
if
(
this
.
state
.
editedValue
===
null
)
{
return
;
}
let
label
=
this
.
state
.
editedValue
.
trim
();
...
...
client/components/operations/search.js
View file @
9c18b912
...
...
@@ -115,7 +115,9 @@ class SearchComponent extends React.Component {
this
.
lowDatePicker
.
clear
();
this
.
highDatePicker
.
clear
();
this
.
props
.
resetAll
();
if
(
close
)
this
.
refSearchPanel
.
handleToggleExpand
();
if
(
close
)
{
this
.
refSearchPanel
.
handleToggleExpand
();
}
event
.
preventDefault
();
}
...
...
@@ -308,8 +310,11 @@ const Export = connect(
return
{
setKeywords
(
keywordsString
)
{
let
keywords
=
keywordsString
.
trim
();
if
(
keywords
.
length
)
keywords
=
keywords
.
split
(
'
'
).
map
(
w
=>
w
.
toLowerCase
());
else
keywords
=
[];
if
(
keywords
.
length
)
{
keywords
=
keywords
.
split
(
'
'
).
map
(
w
=>
w
.
toLowerCase
());
}
else
{
keywords
=
[];
}
actions
.
setSearchField
(
dispatch
,
'
keywords
'
,
keywords
);
},
...
...
client/components/settings/emails/alert-item.js
View file @
9c18b912
...
...
@@ -12,13 +12,17 @@ const AlertItem = props => {
// TODO hoist this logic in the above component.
const
handleSelect
=
event
=>
{
let
newValue
=
event
.
target
.
value
;
if
(
newValue
===
props
.
alert
.
order
)
return
;
if
(
newValue
===
props
.
alert
.
order
)
{
return
;
}
props
.
update
({
order
:
newValue
});
};
const
handleChangeLimit
=
value
=>
{
if
(
Math
.
abs
(
value
-
props
.
alert
.
limit
)
<=
0.001
)
return
;
if
(
Math
.
abs
(
value
-
props
.
alert
.
limit
)
<=
0.001
)
{
return
;
}
props
.
update
({
limit
:
value
});
};
...
...
client/components/settings/emails/config.js
View file @
9c18b912
...
...
@@ -27,13 +27,17 @@ const EmailConfig = props => {
const
handleSubmit
=
()
=>
{
let
email
=
getEmail
();
if
(
!
email
)
return
;
if
(
!
email
)
{
return
;
}
props
.
saveEmail
(
email
);
};
const
handleSendTestEmail
=
()
=>
{
let
email
=
getEmail
();
if
(
!
email
)
return
;
if
(
!
email
)
{
return
;
}
props
.
sendTestEmail
(
email
);
};
...
...
client/components/settings/emails/report-item.js
View file @
9c18b912
...
...
@@ -10,7 +10,9 @@ import ConfirmDeleteModal from '../../ui/confirm-delete-modal';
const
ReportItem
=
props
=>
{
const
handleOnSelectChange
=
event
=>
{
let
newValue
=
event
.
target
.
value
;
if
(
newValue
===
props
.
alert
.
order
)
return
;
if
(
newValue
===
props
.
alert
.
order
)
{
return
;
}
props
.
update
({
frequency
:
newValue
});
};
...
...
client/components/ui/color-picker.js
View file @
9c18b912
...
...
@@ -6,13 +6,19 @@ import RcColorPicker from 'rc-color-picker';
function
convertRGBToHex
(
rgb
)
{
let
hexRed
=
rgb
.
r
.
toString
(
16
).
toUpperCase
();
if
(
hexRed
.
length
<
2
)
hexRed
+=
hexRed
;
if
(
hexRed
.
length
<
2
)
{
hexRed
+=
hexRed
;
}
let
hexGreen
=
rgb
.
g
.
toString
(
16
).
toUpperCase
();
if
(
hexGreen
.
length
<
2
)
hexGreen
+=
hexGreen
;
if
(
hexGreen
.
length
<
2
)
{
hexGreen
+=
hexGreen
;
}
let
hexBlue
=
rgb
.
b
.
toString
(
16
).
toUpperCase
();
if
(
hexBlue
.
length
<
2
)
hexBlue
+=
hexBlue
;
if
(
hexBlue
.
length
<
2
)
{
hexBlue
+=
hexBlue
;
}
return
`#
${
hexRed
}${
hexGreen
}${
hexBlue
}
`
;
}
...
...
client/components/ui/infinite-list.js
View file @
9c18b912
...
...
@@ -34,7 +34,9 @@ export default class InfiniteList extends React.Component {
}
handleScroll
(
e
)
{
if
(
e
)
e
.
preventDefault
();
if
(
e
)
{
e
.
preventDefault
();
}
let
heightAbove
=
this
.
props
.
getHeightAbove
();
...
...
client/errors.js
View file @
9c18b912
...
...
@@ -4,7 +4,9 @@ import errors from '../shared/errors.json';
import
{
translate
as
$t
}
from
'
./helpers
'
;
function
get
(
name
)
{
if
(
typeof
errors
[
name
]
!==
'
undefined
'
)
return
errors
[
name
];
if
(
typeof
errors
[
name
]
!==
'
undefined
'
)
{
return
errors
[
name
];
}
throw
'
unknown exception code!
'
;
}
...
...
client/helpers.js
View file @
9c18b912
...
...
@@ -35,7 +35,9 @@ export const AlertTypes = ['balance', 'transaction'];
const
DEBUG
=
true
;
export
function
debug
(...
args
)
{
if
(
DEBUG
)
console
.
log
(...
args
);
if
(
DEBUG
)
{
console
.
log
(...
args
);
}
}
export
function
assertDefined
(
x
)
{
...
...
@@ -60,7 +62,9 @@ export function stringToColor(str) {
// Int/hash to hex
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
let
s
=
((
hash
>>
(
i
*
8
))
&
0xff
).
toString
(
16
);
while
(
s
.
length
<
2
)
s
+=
'
0
'
;
while
(
s
.
length
<
2
)
{
s
+=
'
0
'
;
}
color
+=
s
;
}
...
...
client/models.js
View file @
9c18b912
...
...
@@ -118,7 +118,9 @@ export class Category {
threshold
=
arg
.
threshold
;
if
(
typeof
threshold
===
'
string
'
)
{
threshold
=
parseFloat
(
threshold
);
if
(
isNaN
(
threshold
))
threshold
=
0
;
if
(
isNaN
(
threshold
))
{
threshold
=
0
;
}
}
}
this
.
threshold
=
threshold
;
...
...
@@ -153,13 +155,16 @@ export class Alert {
// Data for reports
this
.
frequency
=
arg
.
type
===
'
report
'
&&
assertHas
(
arg
,
'
frequency
'
)
&&
arg
.
frequency
;
if
(
arg
.
type
===
'
report
'
)
if
(
arg
.
type
===
'
report
'
)
{
assert
([
'
daily
'
,
'
weekly
'
,
'
monthly
'
].
indexOf
(
arg
.
frequency
)
!==
-
1
);
}
// Data for balance/operation notifications
this
.
limit
=
arg
.
type
!==
'
report
'
&&
assertHas
(
arg
,
'
limit
'
)
&&
arg
.
limit
;
this
.
order
=
arg
.
type
!==
'
report
'
&&
assertHas
(
arg
,
'
order
'
)
&&
arg
.
order
;
if
(
arg
.
type
!==
'
report
'
)
assert
([
'
lt
'
,
'
gt
'
].
indexOf
(
arg
.
order
)
!==
-
1
);
if
(
arg
.
type
!==
'
report
'
)
{
assert
([
'
lt
'
,
'
gt
'
].
indexOf
(
arg
.
order
)
!==
-
1
);
}
}
merge
(
other
)
{
...
...
client/store/banks.js
View file @
9c18b912
...
...
@@ -882,7 +882,9 @@ function reduceDeleteAlert(state, action) {
// Reducers on external actions.
function
reduceDeleteCategory
(
state
,
action
)
{
if
(
action
.
status
!==
SUCCESS
)
return
state
;
if
(
action
.
status
!==
SUCCESS
)
{
return
state
;
}
let
{
id
,
replaceByCategoryId
}
=
action
;
...
...
@@ -952,8 +954,12 @@ function sortOperations(ops) {
ops
.
sort
((
a
,
b
)
=>
{
let
ad
=
+
a
.
date
,
bd
=
+
b
.
date
;
if
(
ad
<
bd
)
return
1
;
if
(
ad
>
bd
)
return
-
1
;
if
(
ad
<
bd
)
{
return
1
;
}
if
(
ad
>
bd
)
{
return
-
1
;
}
let
ac
=
a
.
customLabel
&&
a
.
customLabel
.
trim
().
length
?
a
.
customLabel
:
a
.
title
;
let
bc
=
b
.
customLabel
&&
b
.
customLabel
.
trim
().
length
?
b
.
customLabel
:
b
.
title
;
return
localeComparator
(
ac
,
bc
);
...
...
client/store/categories.js
View file @
9c18b912
...
...
@@ -200,7 +200,9 @@ export function initialState(categories) {
let
items
=
sortCategories
([
NONE_CATEGORY
].
concat
(
categories
).
map
(
c
=>
new
Category
(
c
)));
let
map
=
{};
for
(
let
c
of
items
)
map
[
c
.
id
]
=
c
;
for
(
let
c
of
items
)
{
map
[
c
.
id
]
=
c
;
}
return
u
(
{
...
...
client/store/helpers.js
View file @
9c18b912
...
...
@@ -25,13 +25,17 @@ const _compose = (f, g) => x => g(f(x));
export
function
compose
(...
args
)
{
let
ret
=
args
[
0
];
for
(
let
i
=
1
;
i
<
args
.
length
;
i
++
)
ret
=
_compose
(
ret
,
args
[
i
]);
for
(
let
i
=
1
;
i
<
args
.
length
;
i
++
)
{
ret
=
_compose
(
ret
,
args
[
i
]);
}
return
ret
;
}
export
function
createReducerFromMap
(
initialState
,
map
)
{
return
function
(
state
=
initialState
,
action
)
{
if
(
action
.
type
in
map
)
return
map
[
action
.
type
](
state
,
action
);
if
(
action
.
type
in
map
)
{
return
map
[
action
.
type
](
state
,
action
);
}
return
state
;
};
}
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment