Commit Graph

31 Commits

Author SHA1 Message Date
Javi Martín
8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00
Javi Martín
d0d681a44b Add and apply EmptyLineAfterGuardClause rule
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
2019-10-24 17:56:03 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Senén Rodero Rodríguez
a733bc7b2e Avoid calls to remote census api (legacy) when endpoint is not defined
Also keep the same behavior for test and development environments.
2019-10-21 14:30:03 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
taitus
090390c09f Boy Scout: Create document parser spec file
Regroup DocumentParser spec. Now they're duplicates in
local_census_specs and census_api_spec.

Move duplicate private method "dni?(document_type) from
LocalCensus and CensusAPI to DocumentParser
2019-07-29 13:10:09 +02:00
Bertocq
633cc1283b Fix Date & DateTime parsings to use default timezone
Date.new(...) does not take into account the current timezone, while other
parts of the application do. By default always parsing any date with the
default timezone and converting the resulting Time to Date would prevent
this kind of issues

DateTime.parse(...).in_time_zone gives an unexpected result, as the
DateTime.parse(...) will create a DateTime with +0000 time zone and the
`in_time_zone` will modify the DateTime to adjust to the default zone.

Maybe its better explained with an example, using 'Lima' as timezone:

DateTime.parse("2015-01-01")
> Thu, 01 Jan 2015 00:00:00 +0000

DateTime.parse("2015-01-01").in_time_zone
> Wed, 31 Dec 2014 19:00:00 -05 -05:00

And that's not the desired date but the previous day!
2018-04-04 14:21:39 +02:00
Bertocq
9e4559e374 Revert random district code on census api mock response 2018-01-23 18:38:07 +01:00
Bertocq
c30c47cbb5 Improve default city map with 4 districts, and more real fake geozones 2018-01-23 15:59:24 +01:00
María Checa
20fd8c0515 Officing tests improvements 2017-10-17 20:41:48 +02:00
Bertocq
c2d154b1ac Comply with Style/PredicateName rule for ? method names 2017-09-20 16:12:28 +02:00
Bertocq
69f4e1c683 Fix all rubocop Metrics/LineLength issues (140+) 2017-07-10 13:22:49 +02:00
rgarcia
d80303395b extracts census document parser to a module 2017-05-04 03:39:38 +02:00
rgarcia
b54aee5702 displays voter name if already voted 2016-11-14 13:52:38 +01:00
rgarcia
44df91346a validates voter in census 2016-11-14 13:51:59 +01:00
kikito
edb56b24ce removes lying comment 2016-04-13 14:30:58 +02:00
kikito
1b1f2bc2c9 renames genre to gender in code 2016-04-13 14:27:27 +02:00
kikito
4f724ef3bf Modifies census_api to parse genre and dob 2016-04-12 18:18:25 +02:00
kikito
6229097032 Fixes typo 2016-04-12 13:38:01 +02:00
kikito
9cc831bbc1 adds genre to the census api response 2016-04-11 18:41:33 +02:00
kikito
bcf41c786a Adds district code to census_api 2016-02-19 18:29:14 +01:00
kikito
5e1fba288c refactors method in census_api.rb 2015-12-22 11:49:38 +01:00
kikito
d8e6584bfe fixes comments 2015-12-21 17:10:07 +01:00
kikito
57e72206d2 makes the census api try several variants before failing a verification 2015-12-21 17:07:48 +01:00
kikito
cc1a69c7a5 fixes error in census_api and refactors constructor 2015-09-30 10:56:57 +02:00
kikito
1c372328d9 Refactor in residence verification + census api
Needed for a new census api verification using only the document type
(no date of birth and no postal code)
2015-09-29 20:18:52 +02:00
rgarcia
fbb5db8062 removes unnecessary address from users 2015-09-26 13:45:37 +02:00
rgarcia
abfc93ea78 hot fix to take into account preproduction 2015-09-02 11:36:30 +02:00
rgarcia
0df72b9260 updates census api keys 2015-09-01 20:05:35 +02:00
rgarcia
b9333c7bbe adds hotfix for invalid census api response 2015-08-28 16:43:14 +02:00
kikito
ffad7fbc86 Rename UserApi to CensusApi. Fixes #271 2015-08-28 15:38:22 +02:00