Skip to content

Commit

Permalink
Lint and fix missing trailing newlines (#16445)
Browse files Browse the repository at this point in the history
Apply the Clojure Style Guide recommendation to end files with proper lines
(having a trailing newline character). See
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
  • Loading branch information
ilmotta authored Jul 4, 2023
1 parent 8978e92 commit 19ca8e2
Show file tree
Hide file tree
Showing 50 changed files with 94 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ As a <user|developer|...>, I want to <task> so that <goal>.
[comment]: # (if on Android please replicate bug whilst running adb logcat)
```
...
```
```
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "Usage: make [target]\n\nSee STARTING_GUIDE.md for more info.\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; \
}
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "Usage: make [target]\n\nSee STARTING_GUIDE.md for more info.\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; \
}
HOST_OS := $(shell uname | tr '[:upper:]' '[:lower:]')

# This can come from Jenkins
Expand Down Expand Up @@ -307,6 +307,7 @@ lint: ##@test Run code style checks
clj-kondo --config .clj-kondo/config.edn --cache false --lint src && \
ALL_CLOJURE_FILES=$(call find_all_clojure_files) && \
zprint '{:search-config? true}' -sfc $$ALL_CLOJURE_FILES && \
sh scripts/lint-trailing-newline.sh && \
yarn prettier

# NOTE: We run the linter twice because of https://github.com/kkinnear/zprint/issues/271
Expand All @@ -315,9 +316,9 @@ lint-fix: ##@test Run code style checks and fix issues
ALL_CLOJURE_FILES=$(call find_all_clojure_files) && \
zprint '{:search-config? true}' -sw $$ALL_CLOJURE_FILES && \
zprint '{:search-config? true}' -sw $$ALL_CLOJURE_FILES && \
sh scripts/lint-trailing-newline.sh --fix && \
yarn prettier


shadow-server: export TARGET := clojure
shadow-server:##@ Start shadow-cljs in server mode for watching
yarn shadow-cljs server
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "StatusIm",
"displayName": "StatusIm"
}
}
2 changes: 1 addition & 1 deletion doc/decisions/0012-using-pivotal-tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ The `State` field in the Pivotal story is used to track the progress of a Pivota
| 5 points | 2 - 3 days |
| 8 points | ~1 week |

We should avoid 8 point stories by breaking them down into smaller stories as much as possible.
We should avoid 8 point stories by breaking them down into smaller stories as much as possible.
2 changes: 1 addition & 1 deletion ios/StatusIm/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"version" : 1,
"author" : "xcode"
}
}
}
2 changes: 1 addition & 1 deletion modules/react-native-status/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"url": "https://github.com/status-im/react-native-status/issues"
},
"homepage": "https://github.com/status-im/react-native-status#readme"
}
}
2 changes: 1 addition & 1 deletion resources/config/fleets.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@
}
}
}
}
}
33 changes: 33 additions & 0 deletions scripts/lint-trailing-newline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -eof pipefail

FILES=$(comm -23 <(sort <(git ls-files --cached --others --exclude-standard)) <(sort <(git ls-files --deleted)) | grep --ignore-case -E '\.(java|cpp|nix|json|sh|md|js|clj|cljs|cljc|edn)$')
N_FILES=$(echo "$FILES" | wc -l)
LINT_SHOULD_FIX=0

if [[ -n $1 && $1 != '--fix' ]]; then
echo "Unknown option '$1'" >&2
exit 1
elif [[ $1 == '--fix' ]]; then
LINT_SHOULD_FIX=1
fi

echo "Checking ${N_FILES} files for missing trailing newlines."

# Do not process the whole file and only check the last character. Ignore empty
# files. Taken from https://stackoverflow.com/a/10082466.
for file in $FILES; do
if [ -s "$file" ] && [ "$(tail -c1 "$file"; echo x)" != $'\nx' ]; then
if [[ $LINT_SHOULD_FIX -eq 1 ]]; then
echo "" >>"$file"
else
LINT_ERROR=1
echo "No trailing newline: $file" >&2
fi
fi
done

if [[ $LINT_ERROR -eq 1 ]]; then
exit 1
fi
2 changes: 1 addition & 1 deletion src/quo/previews/icons.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
(for [i (keys icons/icons)]
[rn/view {:flex-direction :row}
[icons/icon (keyword i)]
[rn/text i]])])
[rn/text i]])])
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
{:data [{:id 1
:label "Item 1"}
]} types/tab])
(h/is-truthy (h/get-by-text "Item 1"))))
(h/is-truthy (h/get-by-text "Item 1"))))
2 changes: 1 addition & 1 deletion src/status_im/data_store/invitations.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
(-> message
(clojure.set/rename-keys {:chatId :chat-id
:introductionMessage :introduction-message
:messageType :message-type})))
:messageType :message-type})))
2 changes: 1 addition & 1 deletion src/status_im/fleet/default_fleet.cljs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns status-im.fleet.default-fleet (:require-macros [status-im.utils.slurp :refer [slurp]]))

(def default-fleets
(slurp "resources/config/fleets.json"))
(slurp "resources/config/fleets.json"))
2 changes: 1 addition & 1 deletion src/status_im/keycard/test_menu.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
[button "conn sell" :connect-selected-card simulated-keycard/connect-selected-card]
[button "pair" :connect-pairing-card simulated-keycard/connect-pairing-card]
[button "disc" :disconnect-card simulated-keycard/disconnect-card]
[button "res" :keycard-reset-state simulated-keycard/reset-state]])
[button "res" :keycard-reset-state simulated-keycard/reset-state]])
2 changes: 1 addition & 1 deletion src/status_im/ui/components/checkbox/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
:justify-content :center
:border-radius 2
:width 18
:height 18})
:height 18})
2 changes: 1 addition & 1 deletion src/status_im/ui/components/fast_image.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
(if @error?
[icons/icon :main-icons/cancel]
(when-not @loaded?
[react/activity-indicator {:animating true}]))])])))
[react/activity-indicator {:animating true}]))])])))
2 changes: 1 addition & 1 deletion src/status_im/ui/components/list/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
:android {:margin-bottom 3}
:ios {:margin-bottom 10}})

(def section-header-container {})
(def section-header-container {})
2 changes: 1 addition & 1 deletion src/status_im/ui/components/plus_button.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
[react/activity-indicator
{:color colors/white-persist
:animating true}]
[icons/icon :main-icons/add {:color colors/white-persist}])]]])
[icons/icon :main-icons/add {:color colors/white-persist}])]]])
2 changes: 1 addition & 1 deletion src/status_im/ui/components/slider.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
(def slider (reagent/adapt-react-class Slider))

(def animated-slider
(reagent/adapt-react-class (.createAnimatedComponent Animated Slider)))
(reagent/adapt-react-class (.createAnimatedComponent Animated Slider)))
2 changes: 1 addition & 1 deletion src/status_im/ui/components/tabbar/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
56
(if platform/iphone-x?
84
50)))
50)))
2 changes: 1 addition & 1 deletion src/status_im/ui/components/tabs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
[react/view {:padding-horizontal 12 :padding-vertical 8}
[react/text
{:style {:font-weight "500" :color (if active? colors/white colors/blue) :line-height 22}}
label]]]])
label]]]])
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/chat/styles/message/sheets.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
{:color colors/gray
:padding 24
:line-height 22
:font-size 15})
:font-size 15})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/dapps_permissions/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
:border-radius 20
:background-color colors/gray-lighter
:align-items :center
:justify-content :center})
:justify-content :center})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/help_center/styles.cljs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(ns status-im.ui.screens.help-center.styles)
(ns status-im.ui.screens.help-center.styles)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
:justify-content :space-between})

(def enable-all
{:align-self :flex-end})
{:align-self :flex-end})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/pairing/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
(def bottom-container
{:flex-direction :row
:margin-horizontal 12
:margin-vertical 15})
:margin-vertical 15})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/profile/user/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
(def share-link-button
{:margin-top 12
:margin-horizontal 16
:margin-bottom 16})
:margin-bottom 16})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/qr_scanner/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:right 0
:align-items :center
:justify-content :center
:flex 1})
:flex 1})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/signing/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
:padding-left 16
:color (if disabled? colors/black colors/white-persist)
:padding-horizontal 16
:padding-vertical 10})
:padding-vertical 10})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/stickers/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
:border-radius 14
:background-color colors/green
:align-items :center
:justify-content :center})
:justify-content :center})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/wallet/components/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
(defn separator-dark
[]
{:height 1
:background-color colors/black-transparent})
:background-color colors/black-transparent})
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/wallet/components/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
:style (merge
{:width (or width 40)
:height (or height 40)}
image-style)}]])
image-style)}]])
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/wallet/send/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
:margin-bottom 12
:align-items :center
:justify-content :center
:padding-horizontal 12})
:padding-horizontal 12})
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@

(def app-info-container
{:flex-direction :column
:flex 1})
:flex 1})
2 changes: 1 addition & 1 deletion src/status_im/utils/image.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[photo-path]
(when-not (and (not (string/blank? photo-path))
(string/starts-with? photo-path "contacts://"))
{:uri photo-path}))
{:uri photo-path}))
2 changes: 1 addition & 1 deletion src/status_im/utils/signing_phrase/dictionaries/en.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,4 @@
"yoke"
"yurt"
"zinc"
"zone"])
"zone"])
2 changes: 1 addition & 1 deletion src/status_im/wallet/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
;; ticker on exchange networks. We handle that with `symbol-exchange` override.
(defn exchange-symbol
[{:keys [symbol-exchange symbol-display symbol]}]
(clojure.core/name (or symbol-exchange symbol-display symbol)))
(clojure.core/name (or symbol-exchange symbol-display symbol)))
2 changes: 1 addition & 1 deletion src/status_im2/common/plus_button/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
:accessibility-label (or accessibility-label :plus-button)
:on-press on-press
:customization-color customization-color}
:i/add])
:i/add])
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
:border-width 1})

(def no-pinned-messages-text
{:margin-top 20})
{:margin-top 20})
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
:pinned-by display-name
:child [reply/quoted-message quoted-message false true]
:timestamp-str timestamp-str
:labels {:pinned-a-message (i18n/label :t/pinned-a-message)}}]))
:labels {:pinned-a-message (i18n/label :t/pinned-a-message)}}]))
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@

(defn header-online
[]
{:color (colors/theme-colors colors/neutral-80-opa-50 colors/white-opa-50)})
{:color (colors/theme-colors colors/neutral-80-opa-50 colors/white-opa-50)})
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
(reanimated/apply-animations-to-style
(when enabled?
{:opacity animation})
(pinned-banner top-offset)))
(pinned-banner top-offset)))
2 changes: 1 addition & 1 deletion src/status_im2/subs/browser.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
:bookmarks/active
:<- [:bookmarks]
(fn [bookmarks]
(into {} (remove #(:removed (second %)) bookmarks))))
(into {} (remove #(:removed (second %)) bookmarks))))
2 changes: 1 addition & 1 deletion translations/es_419.json
Original file line number Diff line number Diff line change
Expand Up @@ -1813,4 +1813,4 @@
"your-recovery-phrase-description": "Esta es tu frase semilla. La usas para comprobar que esta es tu billetera. ¡Sólo la verás una vez! Escríbela en un papel y guárdala en un lugar seguro. La necesitarás si pierdes o reinstalas tu billetera.",
"your-tip-limit": "Tu límite de propina",
"youre-on-mobile-network": "Estás en una red móvil"
}
}
2 changes: 1 addition & 1 deletion translations/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -1228,4 +1228,4 @@
"your-keys": "کلیدهای شما",
"your-recovery-phrase": "عبارت دانه شما",
"your-recovery-phrase-description": "این عبارت بازیابی شماست. شما از آن برای اثبات اینکه این کیف پول شماست استفاده می کنید. شما فقط همین یکبار آنرا مشاهده میکنید! آن را روی کاغذ بنویسید و در مکانی امن نگه دارید. اگر کیف پول خود را از دست بدهید یا مجددا نصب کنید، به آن نیاز خواهید داشت."
}
}
2 changes: 1 addition & 1 deletion translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1800,4 +1800,4 @@
"your-recovery-phrase-description": "Ceci est votre phrase de récupération. Vous l'utilisez pour prouver qu'il s'agit de votre portefeuille. Vous ne le voyez qu'une fois! Ecrivez-le sur du papier et conservez-le dans un endroit sûr. Vous en aurez besoin si vous perdez ou réinstallez votre portefeuille.",
"your-tip-limit": "Votre plafond des pourboires",
"youre-on-mobile-network": "Vous êtes sur un réseau mobile"
}
}
2 changes: 1 addition & 1 deletion translations/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1873,4 +1873,4 @@
"your-recovery-phrase-description": "यह आपका बीज वाक्यांश है। आप इसका उपयोग यह साबित करने के लिए करते हैं कि यह आपका बटुआ है। आप इसे केवल एक बार देख सकते हैं! इसे कागज पर लिखकर सुरक्षित स्थान पर रख दें। यदि आप अपना बटुआ खो देते हैं या पुनः स्थापित करते हैं तो आपको इसकी आवश्यकता होगी।",
"your-tip-limit": "आपकी टिप सीमा",
"youre-on-mobile-network": "आप मोबाइल नेटवर्क पर हैं"
}
}
2 changes: 1 addition & 1 deletion translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1906,4 +1906,4 @@
"your-recovery-phrase-description": "これはあなたのシードフレーズです。ウォレットがあなたのものであることを証明するために使用します。一度だけしか見ることができません。紙に書くか安全な場所で保管してください。紛失やアプリを再インストールする際に必要になります。",
"your-tip-limit": "チップ設定値",
"youre-on-mobile-network": "モバイルネットワークを利用しています"
}
}
Loading

0 comments on commit 19ca8e2

Please sign in to comment.