Commit Graph

24 Commits

Author SHA1 Message Date
flexsurfer f89fd8ca54
move status-im under legacy (#18237) 2023-12-19 18:41:30 +01:00
Icaro Motta 390bbdb6ec
Add missing clj-kondo linter for nubank/matcher-combinators (#18091) 2023-12-06 13:39:47 -03:00
Icaro Motta 563f1c588d
Improve test failure readability (#18049)
Problem: failed equality checks as in "(is (= expected actual))" will give a
single, long line of output that for anything but the simplest data structures
is unreadable by humans, and the output doesn't give a useful diff.

Solution: use library https://github.com/nubank/matcher-combinators and its test
directive "match?" which will pinpoint where two data structures differ. Then,
instead of "(is (= ...", use "(is (match? expected actual)". It works
beautifully.

The library offers other nice matchers, but the majority of the time match? is
sufficient.

Can we use another test runner like Kaocha? kaocha-cljs2
(https://github.com/lambdaisland/kaocha-cljs2) would be able to print better
test errors out of the box, among other features, but I have no clue if it would
work well or at all in our stack (in theory yes, but it's a larger piece of
work).
2023-12-05 17:20:54 -03:00
Icaro Motta c1dcd7a764
Introduce malli library (#17867)
This commit is the foundational step to start using malli
(https://github.com/metosin/malli) in this project.

Take in consideration we will only be able to realize malli's full power in
future iterations.

For those without context: the mobile team watched a presentation about malli
and went through a light RFC to put everyone on the same page, among other
discussions here and there in PRs.

To keep things relatively short:

1. Unit, integration and component tests will short-circuit (fail) when
   inputs/outputs don't conform to their respective function schemas (CI should
   fail too).
2. Failed schema checks will not block the app from initializing, nor throw an
   exception that would trigger the LogBox. Exceptions are only thrown in the
   scope of automated tests.
3. There's zero performance impact in production code because we only
   instrument. Instrumentation is removed from the compiled code due to the
   usage of "^boolean js.goog/DEBUG".
4. We shouldn't expect any meaningful slowdown during development.

**What are we instrumenting in this PR?**

Per our team's agreement, we're only instrumenting the bare minimum to showcase 2 examples.

- Instrument a utility function utils.money/format-amount using the macro
  approach.
- Instrument a quo component quo.components.counter.step.view/view using the
  functional approach.

Both approaches are useful, the functional approach is powerful and allow us to
instrument anonymous functions, like the ones we pass to subscriptions or event
handlers, or the higher-order function quo.theme/with-theme. The macro approach
is perfect for functions already defined with defn.

**I evaluated the schema or function in the REPL but nothing changes**

- If you evaluate the source function, you need to evaluate schema/=> or
  schema/instrument as well.
- Remember to *var quote* when using schema/instrument.
- You must call "(status-im2.setup.schema/setup!)" after any var is
  re-instrumented. It's advisable to add a keybinding in your editor to send
  this expression automatically to the CLJS REPL, or add the call at the end of
  the namespace you are working on (similar to how some devs add "(run-tests)"
  at the end of test namespaces).

**Where should schemas be defined?**

For the moment, we should focus on instrumenting quo components, so define each
function schema in the same namespace as the component's public "view" var.

To be specific:

- A schema used only to instrument a single function and not used elsewhere,
  like a quo component schema, wouldn't benefit from being defined in a separate
  namespace because that would force the developer to constantly open two files
  instead of one to check function signatures.
- A common schema reused across the repo, like ":schema.common/theme" should be
  registered in the global registry "schema.registry" so that consumers can just
  refer to it by keyword, as if it was a built-in malli schema.
- A common schema describing status-go entities like message, notification,
  community, etc can be stored either in the respective
  "src/status_im2/contexts/*" or registered globally, or even somewhere else.
  This is yet to be defined, but since I chose not to include schemas for them,
  we can postpone this guideline.
2023-11-18 11:04:48 -03:00
Icaro Motta 7ae96e86f1
Enable ns sorting linter and clean+sort all namespaces (#17618) 2023-10-16 22:03:18 +00:00
Icaro Motta 7f960f9be5
Add custom linter for i18n/label translation keywords (#17610)
This commit adds a custom linter to verify i18n/label is called with a qualified
keyword, like :t/foo. More sophisticated linters are possible too.

We also set the stage for other developers to consider more lint automation
instead of manually reviewing conventions in PRs.

If you want to understand how to write custom linters, check out
https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md. You can fire
the Clojure JVM REPL in status-mobile and play with the clj-kondo hook too, it
works beautifully.

Why do we care? By making sure all translation keywords are qualified with "t",
it is trivial to grep or replace them because they're unique in the repo, and
can't be confused with other words if you search by ":t/<something>".

Note: It's a best practice to commit clj-kondo configuration from external
libraries in the .clj-kondo directory. The directory .clj-kondo/babashka is
auto-generated, that's why it was added.
2023-10-11 18:53:34 -03:00
Icaro Motta b73ac6b107
Upgrade clj-kondo and configure new linters (#17543)
- Upgrade clj-kondo to latest version to take advantage of new linters. From
  version 2023.04.14
  https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20230414 to
  2023.09.07
  https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20230907
- Use new linter ":unused-alias" and set at WARN level for the moment, because
  otherwise the PR would increase a bit too much, but it did catch many unused
  "require" aliases. Added in version 2023.09.07
  https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20230907
- Use new linter ":case-symbol-test" and fix the reported errors, added in
  version 2023.07.13
  https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20230713
- Use new linters ":equals-true", ":plus-one", and ":minus-one" and fix reported
  errors, added in version 2023.05.18
  https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20230518
- Raise level from WARN to ERROR for linter "uninitialized-var".
- Explicitly add ":case-duplicate-test" to clj-kondo config, renamed in version
  2023.07.13
  https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20230713
- Explicitly add ":case-quoted-test" to clj-kondo config, renamed in version
  2023.07.13
  https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20230713
- Explicitly add ":deprecated-namespace" to clj-kondo config, added in version
  2023.07.13
  https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20230713

Fixes https://github.com/status-im/status-mobile/issues/17287
2023-10-05 15:50:57 -03:00
Icaro Motta e2f837fcbc
Raise clj-kondo linter levels (#17289)
Recently, we changed clj-kondo default fail-level from "warning" to "error", but
we missed the fact that we needed to raise the default level for all linters set
to "warning".
2023-09-14 11:28:43 -03:00
Icaro Motta 857c9c2f74
Unshadow remaining core & non-core vars (#17138)
Unshadows all remaining vars in status-mobile, including non
cljs.core/clojure.core ones. The only exceptions are cljs.core/type and
cljs.core/name (which happen quite often, so I'm not sure if it's worth
unshadowing them).
2023-09-01 11:54:53 +00:00
Icaro Motta 238e35a281
Unshadow more Clojure core vars (#16777)
This is a continuation of https://github.com/status-im/status-mobile/pull/16500 (Lint
& fix some shadowed core Clojure(Script) vars).

Notes: As a reminder, the goal is to eventually disallow shadowing core Clojure
vars entirely, but to get there and avoid rebase hell and regressions, we need
to do in smaller steps, especially because we can't safely automate the process
of unshadowing vars.

We are already down from ~500 shadowed core vars to 350 in total.

Why is this PR is using names such as "s", "v" or "sym"? Names such as s or v
are the so called idiomatic names, and are listed in the Clojure Style Guide
https://guide.clojure.style/#idiomatic-names. I used them whenever I felt
appropriate. For the var cljs.core/symbol I opted to use sym, even though the
symbol in question is not necessarily a Clojure symbol, I think the alias
conveys the meaning well enough
(https://www.clojure.org/guides/learn/syntax#_symbols_and_idents).

New vars linted:

- comparator
- identity
- str
- symbol
- val

Outstanding shadowed vars include type, name, hash, comp.
2023-07-26 11:26:12 +00:00
Icaro Motta 9ed68ee7d1
Lint & fix some shadowed core Clojure(Script) vars (#16500)
It's well known that shadowing core Clojure vars can lead to unexpected bugs. In
fact, it's a common source of bugs in other languages too. In the status-mobile
repository there are, in total, 562 shadowed vars, ~500 are core vars. Excluding
the "old code" we still have 285 offenders.

In status-mobile I've already seen two bugs caused by shadowed vars, both with
the shadowed var "name". But probably other problems happened in the past, and
others will happen in the future if we don't do something about this. This PR is
also my response to my frustration trying to review PRs and checking for
shadowed vars, humans were not meant for that!

In this commit we are enabling ":shadowed-var" to lint certain (not all) core
vars as errors (not warnings). In future PRs we can gradually unshadow more
vars. For the record, name is shadowed 40 times in the new code and 130 in
total, and type is shadowed 93 times in the new code and 124 in total!

What about non-core vars, should we allow shadowing? There are ~70 non-core
shadowed vars. In my opinion, we should also lint and disallow shadowing
non-core vars, since it may cause the same kind of bugs of shadowing core vars.
But this decision can be left for another moment/issue, after we have fixed the
most prominent problem of shadowing core vars.

Which vars are unshadowed in this PR? I fixed 62 errors and unshadowed
cljs.core/iter, cljs.core/time, cljs.core/count, cljs.core/key,
clojure.core/key.

Resources:

- [clj-kondo linter: shadowed-var](https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#shadowed-var)
2023-07-06 10:28:07 +00:00
Icaro Motta 7cf17b5d34
Move unit test helper namespace to `src/test_helpers/` (#14716) 2023-01-05 11:58:37 -03:00
Icaro Motta bad796db90
Fix clojure.set and clojure.walk inconsistent namespace aliases (#14715) 2023-01-05 10:54:32 -03:00
yqrashawn 01660765b7
refactor: delete message related code (#14548) 2022-12-20 21:42:50 +08:00
Icaro Motta 5693df5a74
Lint namespace aliases (#14526) 2022-12-13 17:04:26 -03:00
Icaro Motta 6e272a96c8
Introduce subscription tests (#14472) 2022-12-06 13:36:05 -03:00
flexsurfer 31b6e076be
new structure continue, move utils, move fx macro to re-frame utils n… (#14373)
* new structure continue, move utils, move fx macro to re-frame utils namespace
2022-11-16 09:09:25 +01:00
Parvesh Monu 1047c26f69
Switcher and Bottom Tabs Animations and UI Performance Improvements
- Migrated Switcher animations to Reanimated V2
- Added bottom tabs & Stacks Animations
- Improved bottom tabs, tab changing performance
- Polished android & IOS UI
2022-06-28 23:51:24 +05:30
Gheorghe Pinzaru c7009ff6f7
Add request/approve communites
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2021-02-26 15:38:19 +01:00
Gheorghe Pinzaru 12aa20f467
Add bottom sheet
EXPERIMENTAL: uses reanimated lib so we can use reanimated buttons inside and have simultaneous handlers

Add react hooks

Use hooks

mocks

Use timing for drag transition

Use view on android

Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
2020-06-02 18:10:27 +03:00
yenda 1bf68094e3
add clj-kondo to linting phase
Signed-off-by: yenda <eric@status.im>
2020-05-07 10:40:30 +02:00
Gheorghe Pinzaru 01452794a1
Add text input and tooltip components
Add tooltip component
Add text input component
rename

Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
2020-05-04 16:38:26 +03:00
yenda d5ef218584
use shadow-cljs
Signed-off-by: Jakub Sokołowski <jakub@status.im>
Signed-off-by: yenda <eric@status.im>
2020-04-30 15:43:46 +02:00
Roman Volosovskyi 0efc1a32fe
clj-kondo configuration for Status specific macroses 2019-11-26 15:16:52 +02:00