Skip to content

Conversation

@harutiro
Copy link
Owner

@harutiro harutiro commented Apr 19, 2025

Summary by CodeRabbit

  • 新機能

    • 新しい天気APIインターフェースとその実装クラスを追加しました。
    • 都道府県IDを表す列挙型CityIdを導入しました。
    • 天気リポジトリインターフェースを追加し、全国および都道府県単位での天気取得をサポートしました。
  • バグ修正

    • インポートパスやパッケージ名の表記揺れを修正し、安定性と一貫性を向上させました。
  • スタイル

    • コード全体でフォーマットやインデント、トレーリングカンマの統一、不要な空白・改行の整理を行いました。
  • テスト

    • Kotlinテスト依存関係を追加し、テストコードのインポートを整理しました。
  • ドキュメント

    • コメントや改行の調整により、可読性を改善しました。

@coderabbitai
Copy link

coderabbitai bot commented Apr 19, 2025

Walkthrough

この変更では、プロジェクト全体にわたる大規模なリファクタリングとスタイル統一が行われています。主な内容は、パッケージ名「Weather」から「weather」への統一、インポートパスの修正、コードのフォーマット(トレーリングカンマやインデントの統一)、未使用インポートの削除、新たなテスト依存関係の追加です。また、CityIdNationwideWeatherApiなどのエンティティやAPIインターフェースのファイルが新しいパッケージに移動・再作成され、旧ファイルは削除されています。機能的な変更はほとんどなく、主に構造と可読性の向上が目的です。

Changes

ファイル/グループ 変更概要
app/build.gradle.kts フォーマット調整、Kotlinテスト依存関係追加
app/src/androidTest/java/net/harutiro/nationalweather/ExampleInstrumentedTest.kt, app/src/test/java/net/harutiro/nationalweather/ExampleUnitTest.kt import整理、特定メソッドimportへ変更
app/src/main/java/net/harutiro/nationalweather/Application.kt, MainActivity.kt 未使用import削除、フォーマット統一
core/entities/BottomNavigationItem.kt, core/presenter/BottomNavigationBar.kt, core/presenter/detail/page/DetailPage.kt, core/presenter/detail/page/DetailWeatherCell.kt, core/presenter/favorite/page/FavoritePage.kt, core/presenter/favorite/page/FavoriteWeatherCell.kt, core/presenter/favorite/viewModel/FavoriteViewModel.kt, core/presenter/home/page/HomePage.kt, core/presenter/home/page/NationwideWeatherCell.kt, core/presenter/home/viewModel/HomeViewModel.kt, core/presenter/widget/BookmarkButton.kt, core/presenter/widget/LoadingPage.kt, core/router/Router.kt, core/router/RouterViewModel.kt, core/utils/DateUtils.kt, core/utils/room/AppDatabase.kt, core/utils/room/typeConverter/CityIdConverter.kt, core/utils/room/typeConverter/DateConverter.kt, core/widgets/ArrowBackButton.kt, core/widgets/Center.kt フォーマット調整(トレーリングカンマ、インデント、スペース)、未使用import削除、パッケージ名修正
ui/theme/Color.kt, ui/theme/Theme.kt, ui/theme/Type.kt フォーマット調整、改行追加
features/Weather/apis/NationwideWeatherApi.kt, features/Weather/entities/CityId.kt 旧ファイル削除(パッケージ名大文字)
features/Weather/apis/NationwideWeatherApiImpl.kt, features/Weather/entities/Weather.kt, features/Weather/repositories/NationwideWeatherRepository.kt, features/Weather/repositories/NationwideWeatherRepositoryImpl.kt パッケージ名小文字へ修正、import修正、フォーマット調整
features/weather/apis/NationwideWeatherApi.kt, features/weather/apis/NationwideWeatherApiImpl.kt, features/weather/entities/CityId.kt, features/weather/repositories/NationwideWeatherRepository.kt 新規追加:APIインターフェース、実装、エンティティ、リポジトリ(パッケージ名小文字)
features/weather/apis/NationwideWeatherApiBuilderInterface.kt パッケージ名修正、改行追加
features/weather/entities/Weather.kt パッケージ名修正、フォーマット調整
features/favoriteDB/apis/WeatherFavoriteApi.kt, features/favoriteDB/apis/WeatherFavoriteApiImpl.kt, features/favoriteDB/apis/WeatherFavoriteDao.kt, features/favoriteDB/entities/WeatherFavoriteEntity.kt, features/favoriteDB/repositories/WeatherFavoriteRepository.kt, features/favoriteDB/repositories/WeatherFavoriteRepositoryImpl.kt CityIdのimportパス修正、フォーマット調整

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant ViewModel
    participant Repository
    participant ApiImpl

    UI->>ViewModel: 都市IDで天気取得要求
    ViewModel->>Repository: getPrefectureWeather(cityId)
    Repository->>ApiImpl: getNationwideWeather(cityId)
    ApiImpl-->>Repository: Weatherデータ返却
    Repository-->>ViewModel: Weatherデータ返却
    ViewModel-->>UI: Weatherデータ表示
Loading

Poem

うさぎの耳でコードを見て、
パッケージ小文字で統一だ!
カンマとスペース、整列して、
天気の道もすっきりさ。
テストも追加、春の兆し、
うさぎは今日も跳ねながら、
綺麗なコードに大満足! 🐰🌦️

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e0a8be and 8daab41.

📒 Files selected for processing (1)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApiImpl.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApiImpl.kt

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
app/src/main/java/net/harutiro/nationalweather/core/presenter/widget/LoadingPage.kt (2)

21-24: modifier の配置を簡潔に
現在 modifier =Modifier を別行に分けてインデントしていますが、以下のように modifier = Modifier を同じ行に置き、その後でメソッドチェーンを継続するとより可読性が向上します。

-CircularProgressIndicator(
-    modifier =
-        Modifier
-            .width(64.dp)
-            .height(64.dp),
+CircularProgressIndicator(
+    modifier = Modifier
+        .width(64.dp)
+        .height(64.dp),
     color = MaterialTheme.colorScheme.secondary,
     trackColor = MaterialTheme.colorScheme.surfaceVariant,
 )

36-41: プレビュー関数名の一貫性
LoadingScrollColumnPreview という名称は、このファイル中の LoadingPage と整合していません。プレビュー対象の Composable 名に合わせて LoadingPagePreview などにリネームすると、意図がより明確になります。

app/src/main/java/net/harutiro/nationalweather/core/widgets/ArrowBackButton.kt (1)

16-16: 引数末尾のトレーリングコンマ追加を承認します。
将来パラメータを追加する際の差分が小さくなるメリットがあります。

なお、contentDescription は多言語対応を見越して stringResource を使うとさらに柔軟になります。

contentDescription = stringResource(R.string.back_button_description),
app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/page/DetailWeatherCell.kt (1)

82-87: ImageLoader ビルダーの整形を承認します。
ただし、毎回新規ビルダーを生成するとパフォーマンスに影響する可能性があるため、必要に応じてシングルトン化を検討すると良いでしょう。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 975aa2e and f9b52f3.

📒 Files selected for processing (42)
  • app/build.gradle.kts (4 hunks)
  • app/src/androidTest/java/net/harutiro/nationalweather/ExampleInstrumentedTest.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/Application.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/MainActivity.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/entities/BottomNavigationItem.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/BottomNavigationBar.kt (5 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/page/DetailPage.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/page/DetailWeatherCell.kt (5 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/viewModel/DetailViewModel.kt (3 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoritePage.kt (4 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoriteWeatherCell.kt (7 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/viewModel/FavoriteViewModel.kt (3 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/home/page/HomePage.kt (3 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/home/page/NationwideWeatherCell.kt (6 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/home/viewModel/HomeViewModel.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/widget/BookmarkButton.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/widget/LoadingPage.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/router/Router.kt (3 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/router/RouterViewModel.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/utils/DateUtils.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/utils/room/AppDatabase.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/utils/room/typeConverter/CityIdConverter.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/utils/room/typeConverter/DateConverter.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/widgets/ArrowBackButton.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/widgets/Center.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/apis/NationwideWeatherApi.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/apis/NationwideWeatherApiBuilderInterface.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/apis/NationwideWeatherApiImpl.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/entities/CityId.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/entities/Weather.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/repositories/NationwideWeatherRepository.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/repositories/NationwideWeatherRepositoryImpl.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteApi.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteApiImpl.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteDao.kt (0 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/entities/WeatherFavoriteEntity.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepository.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepositoryImpl.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/ui/theme/Color.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/ui/theme/Theme.kt (3 hunks)
  • app/src/main/java/net/harutiro/nationalweather/ui/theme/Type.kt (2 hunks)
  • app/src/test/java/net/harutiro/nationalweather/ExampleUnitTest.kt (2 hunks)
💤 Files with no reviewable changes (1)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteDao.kt
🧰 Additional context used
🧬 Code Graph Analysis (5)
app/src/main/java/net/harutiro/nationalweather/core/presenter/widget/LoadingPage.kt (1)
app/src/main/java/net/harutiro/nationalweather/core/widgets/Center.kt (1)
  • Center (10-22)
app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/viewModel/FavoriteViewModel.kt (2)
app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepository.kt (3)
  • deleteFavorite (10-10)
  • insertFavorite (7-15)
  • insertFavorite (8-8)
app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepositoryImpl.kt (2)
  • deleteFavorite (37-49)
  • insertFavorite (16-35)
app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoritePage.kt (1)
app/src/main/java/net/harutiro/nationalweather/core/presenter/widget/LoadingPage.kt (1)
  • LoadingPage (13-32)
app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepositoryImpl.kt (1)
app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteDao.kt (2)
  • WeatherFavoriteEntity (22-23)
  • WeatherFavoriteEntity (25-26)
app/src/main/java/net/harutiro/nationalweather/core/router/Router.kt (3)
app/src/main/java/net/harutiro/nationalweather/core/presenter/home/page/HomePage.kt (1)
  • HomePage (21-58)
app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoritePage.kt (1)
  • FavoritePage (33-98)
app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/page/DetailPage.kt (1)
  • DetailPage (33-83)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gradle
🔇 Additional comments (137)
app/src/main/java/net/harutiro/nationalweather/features/Weather/entities/CityId.kt (1)

50-51: トレーリングカンマの追加により可読性と差分管理が向上
enumエントリの最後にカンマを配置し、次行でセミコロンを宣言子として分離することで、今後エントリ追加時のGit差分がより明確になります。動作には影響しない良いリファクタリングです。

app/src/main/java/net/harutiro/nationalweather/MainActivity.kt (1)

21-21: トレーリングカンマの追加による整形確認
Surface コールの引数リストにトレーリングカンマを追加しており、Kotlin のマルチライン引数記述時の可読性と一貫性が向上しています。機能的な変更はなく、問題ありません。

app/src/main/java/net/harutiro/nationalweather/core/widgets/Center.kt (1)

22-22: ファイル末尾に改行を追加
POSIX互換性を高め、エディタやdiffツールで末尾行が正しく扱われるようになる良い修正です。

app/src/main/java/net/harutiro/nationalweather/core/utils/room/typeConverter/CityIdConverter.kt (1)

16-16: 末尾の改行を追加
ファイル末尾に改行を追加し、UNIX 系ツールとの互換性とエディタでの表示品質を向上させています。

app/src/main/java/net/harutiro/nationalweather/core/utils/room/typeConverter/DateConverter.kt (2)

11-11: 可読性向上のための空行追加
fromTimestamp メソッドの終了後に空行を挿入し、メソッド間の視認性を高めています。


16-16: 末尾の改行を追加
ファイル末尾に改行を追加し、エディタやバージョン管理での diff がよりクリーンになるよう調整されています。

app/src/main/java/net/harutiro/nationalweather/core/utils/room/AppDatabase.kt (2)

12-12: @TypeConverters のカンマ後にスペースを追加
CityIdConverter::class,DateConverter::class から CityIdConverter::class, DateConverter::class へ変更し、一貫したコードスタイルを維持しています。


15-15: 末尾の改行を追加
ファイル末尾に改行を追加し、ツールやエディタでの表示を最適化しています。

app/src/main/java/net/harutiro/nationalweather/core/presenter/widget/LoadingPage.kt (1)

16-17: パラメータリストの末尾カンマ追加が適切です
関数 LoadingPage のパラメータリストにトレーリングカンマを追加しており、他の Composable 関数(例: Center)とスタイルが一致しています。

app/src/main/java/net/harutiro/nationalweather/features/Weather/entities/Weather.kt (3)

6-7: パラメータリスト末尾のトレーリングカンマと括弧位置の調整が適切です
Kotlinの公式ガイドラインに沿ったフォーマットで、可読性と差分の明確化に貢献しています。


8-12: companion object と関数シグネチャのスペース付与が一貫しています
fun getCityAcquisition(title: String): String { のようにブレース前にスペースを挿入するスタイルは、コード全体の一貫性を保つ上で適切です。


22-26: Image クラスのトレーリングカンマと末尾改行追加が適切です
データクラスのプロパティリスト末尾にカンマを置き、ファイル末尾に空行を入れることで、今後のdiff管理とKotlinスタイルガイドへの準拠が行われています。

app/src/main/java/net/harutiro/nationalweather/ui/theme/Theme.kt (5)

18-23: DarkColorScheme定義のマルチライン化と末尾カンマ追加
darkColorScheme の引数リストが複数行に分かれ、末尾カンマが追加されています。可読性とDiffの明確化に寄与しており、問題ありません。


25-29: LightColorScheme定義のマルチライン化と末尾カンマ追加
lightColorScheme の引数リストでも同様に整形されており、一貫性が保たれています。OKです。


45-47: Composable関数パラメータリストの整形と末尾カンマ追加
NationalWeatherTheme のパラメータリストで dynamicColorcontent がマルチライン化され、末尾カンマが追加されています。コードスタイルの一貫性向上に貢献しています。


48-57: colorScheme選択ロジックの整形
when ブロックがインデント調整と空行による可読性向上のために整形されています。ロジックに変更はなく、スタイル改善として適切です。


67-72: MaterialTheme呼び出しのパラメータ整形と末尾カンマ追加
MaterialTheme の引数リストもマルチライン化され、末尾カンマを追加して可読性を高めています。良好です。

app/src/main/java/net/harutiro/nationalweather/ui/theme/Color.kt (1)

11-11: ファイル末尾の改行追加
ファイル末尾に改行が追加されました。機能的な変更はなく、スタイルの一貫性維持に寄与しています。

app/src/main/java/net/harutiro/nationalweather/ui/theme/Type.kt (2)

10-19: Typography定義のマルチライン化と末尾カンマ追加
Typography の初期化で引数リストが複数行に分かれ、末尾カンマが追加されて可読性が向上しています。問題ありません。


35-36: コメントアウトブロックと閉じ括弧の整形
コメントアウトされた他のスタイル定義と閉じ括弧 ) のインデントおよび位置が調整され、一貫性が確保されています。

app/src/main/java/net/harutiro/nationalweather/features/Weather/apis/NationwideWeatherApi.kt (1)

8-8: 末尾改行の追加を確認しました
ファイルの終端に改行が追加され、他ファイルと同様のフォーマット規約に統一されています。

app/src/main/java/net/harutiro/nationalweather/core/entities/BottomNavigationItem.kt (1)

12-13: データクラスのプロパティリストにトレーリングカンマを追加
path プロパティの後にトレーリングカンマを付与し、パラメータリストのフォーマットが一貫しました。

app/src/main/java/net/harutiro/nationalweather/features/Weather/apis/NationwideWeatherApiBuilderInterface.kt (1)

13-13: 末尾改行の追加を確認しました
EOFに改行が入り、他ファイルと同様にファイル末尾のフォーマットが統一されています。

app/src/main/java/net/harutiro/nationalweather/Application.kt (3)

7-7: クラス宣言のスペース調整
class Application : Application() のコロン周りのスペースが整理され、Android標準クラスの継承宣言が読みやすくなっています。


16-21: Room.databaseBuilder 呼び出しのマルチライン整形
ビルダー引数を改行・インデントで分割し、末尾にトレーリングカンマを追加することで可読性が向上しています。


23-23: 末尾改行の追加を確認しました
ファイル末尾に改行が追加され、フォーマットが一貫しています。

app/src/main/java/net/harutiro/nationalweather/core/presenter/widget/BookmarkButton.kt (5)

16-16: Composable関数のパラメータにトレーリングカンマを追加
onClick: () -> Unit, にトレーリングカンマを付与し、パラメータリストの書式が他と揃っています。


19-19: IconButton呼び出しの引数リストにトレーリングカンマを追加
onClick = onClick, にトレーリングカンマを追加し、一貫したフォーマットになっています。


23-23: Icon呼び出しの引数リストにトレーリングカンマを追加
contentDescription = null, にトレーリングカンマを追加し、引数リストのフォーマットが統一されています。


31-34: Preview関数内の状態ホルダー宣言をマルチライン化
remember { mutableStateOf(false) } の初期化ロジックを改行で分割し、可読性を向上させています。


40-42: BookmarkButton呼び出しの引数リストにトレーリングカンマを追加
ラムダ引数および呼び出し全体の末尾にトレーリングカンマが入り、フォーマットが一貫しました。

app/src/main/java/net/harutiro/nationalweather/core/utils/DateUtils.kt (4)

7-7: companion object キーワードのフォーマット修正を承認します。
companion object { とすることでブレースとの間に空白が入り、可読性が向上しています。


11-12: SimpleDateFormat 呼び出しの引数間にスペースを追加したことを承認します。
"MM月dd日 (E)", java.util.Locale.JAPAN のようにカンマ後にスペースを入れることで、一貫したコードスタイルになっています。


18-19: 同様に apiDateToJapaneseNotation 内の SimpleDateFormat でもスペース追加を承認します。
コード全体でカンマ後の空白有無が統一され、可読性が保たれています。


22-22: ファイル末尾に改行を追加したことを承認します。
EOF 後の改行があることで、多くのエディタ・Lint ルールとも整合します。

app/src/main/java/net/harutiro/nationalweather/core/widgets/ArrowBackButton.kt (2)

10-10: シングルライン関数シグネチャへのフォーマット変更を承認します。
パラメータリストが一行でまとまり、シンプルになりました。


19-19: ファイル末尾に改行を追加したことを承認します。

app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/page/DetailWeatherCell.kt (8)

38-42: Cardmodifier チェーン呼び出しの整形を承認します。
メソッドチェーンを改行してインデントすることで、可読性が向上しています。


52-56: WeatherImagemodifier チェーン呼び出しの整形を承認します。
同様にインデントを揃え、見通しが良くなりました。


58-61: Column のパラメータリスト末尾にトレーリングコンマを追加したことを承認します。
将来属性を追加するときの差分ノイズが減ります。


107-113: TextStyle のネストしたパラメータ整形を承認します。
各プロパティを改行・インデントすることで読みやすくなっています。


117-123: 2つ目の Text に対する TextStyle 整形を承認します。
同様にスタイル定義が見やすく統一されています。


129-136: WeatherDate のパラメータリストおよびスタイル定義整形を承認します。
他の Composable と一貫したレイアウトです。


148-148: プレビューの modifier にトレーリングコンマを追加したことを承認します。
将来プロパティ追加時の差分が安定します。


159-159: ファイル末尾の改行追加を承認します。

app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/viewModel/DetailViewModel.kt (3)

18-18: コンストラクタパラメータ末尾のトレーリングコンマ追加を承認します。
複数行パラメータが整い、差分も小さくなります。


35-36: updateBookmark 関数のシグネチャ整形を承認します。
単一行にまとめることで可読性が向上し、コード量も削減されています。


47-47: ファイル末尾の改行追加を承認します。

app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/page/DetailPage.kt (6)

23-26: インポートグループの整理を承認します。
Compose 固有の import をまとめ、関連ライブラリの import が一貫した順序で並んでいます。


35-39: DetailPage 関数シグネチャの多行整形を承認します。
各パラメータが独立しており、可読性が高まりました。


55-60: TopAppBar 呼び出しブロックの整形を承認します。
navigationIcon からラムダ全体にかけてインデント・改行が統一され、差分追跡が容易です。


65-68: actions 内の BookmarkButton パラメータ整形を承認します。
トレーリングコンマを含め、将来の変更時に差分が小さくなります。


69-74: showSnackbar 周りのラムダ内インデント・改行整形を承認します。
複数ステップのネストが見やすく保たれています。


93-93: Detail3DaysList 内の modifier にトレーリングコンマを追加したことを承認します。

app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteApiImpl.kt (1)

29-29: ファイル末尾の改行追加は問題ありません
フォーマット統一のための変更であり、機能には影響を与えません。

app/src/test/java/net/harutiro/nationalweather/ExampleUnitTest.kt (1)

3-3: JUnitインポートのワイルドカードから個別インポートへの切り替え
assertEquals のみを明示的にインポートすることで可読性とIDEの補完精度が向上します。ファイル末尾の改行追加も良好です。

Also applies to: 16-16

app/src/androidTest/java/net/harutiro/nationalweather/ExampleInstrumentedTest.kt (1)

4-5: インポート整理と個別インポートの適用
InstrumentationRegistry の位置調整と assertEquals のワイルドカード削除によるフォーマット改善です。ファイル末尾の改行追加も含め問題ありません。

Also applies to: 22-22

app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteApi.kt (1)

8-8: メソッド宣言後の空行追加による可読性向上
各メソッド宣言後に空行を挿入するスタイル整備であり、API仕様には影響しません。

Also applies to: 10-10, 12-12, 14-14, 16-16

app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepository.kt (1)

8-8: インターフェースメソッド間の空行挿入
フォーマットの一貫性を保つための変更で、機能には影響ありません。

Also applies to: 10-10, 13-13, 15-15

app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/entities/WeatherFavoriteEntity.kt (2)

14-15: 引数リストへの末尾カンマ追加と閉じ括弧移動
トレーリングカンマを追加し、閉じ括弧の位置を揃えることでデータクラスのパラメータリストの可読性と一貫性が向上しています。


16-19: companion object の改行・インデント調整
companion object のインデントとファイル末尾の改行を整え、スタイルの統一性が保たれています。

app/src/main/java/net/harutiro/nationalweather/features/Weather/repositories/NationwideWeatherRepository.kt (1)

9-12: インターフェースメソッドシグネチャのスペーシング統一
コロン前後のスペーシングと改行を標準化し、可読性が向上しています。

app/src/main/java/net/harutiro/nationalweather/core/router/RouterViewModel.kt (1)

7-10: クラス宣言のコロン周りスペース追加
RouterViewModel : ViewModel() とすることでスペーシングの一貫性が保たれています。

app/src/main/java/net/harutiro/nationalweather/core/presenter/home/viewModel/HomeViewModel.kt (3)

14-14: コンストラクタパラメータ末尾にトレーリングカンマを追加
引数リストにトレーリングカンマを追加し、後続のパラメータ変更時にも差分が小さくて済むようになっています。


19-19: isLoading宣言後の空行挿入
論理ブロック間に空行を入れて可読性を高めています。


30-30: ファイル末尾の改行追加
POSIX準拠のため、ファイル末尾に改行を追加しています。

app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/viewModel/FavoriteViewModel.kt (4)

17-18: コンストラクタパラメータのトレーリングカンマと改行移動
ViewModelの引数リストにトレーリングカンマを加え、閉じ括弧位置を調整してフォーマットを統一しています。


46-46: ifステートメントのスペーシング調整
if (condition) { の形式に統一し、可読性を向上させています。

Also applies to: 53-53, 67-67


65-66: updateBookmarkのパラメータリストにトレーリングカンマ追加
ラムダ引数リスト末尾にカンマを入れており、今後の引数追加時に差分が最小限になります。


77-77: ファイル末尾の改行追加
ファイル末尾に改行を追加し、スタイルを統一しています。

app/src/main/java/net/harutiro/nationalweather/features/Weather/apis/NationwideWeatherApiImpl.kt (7)

13-14: クラス宣言とメソッドシグネチャの整形
NationwideWeatherApiImpl クラスと getNationwideWeather メソッドのシグネチャが適切に整形され、可読性が向上しています。


16-19: HttpLoggingInterceptor のインデント調整
ロギング用インターセプター生成部分のラムダネストが揃えられ、読みやすくなっています。


22-25: OkHttpClient ビルダーのチェーン書式統一
.addInterceptor.build() のメソッドチェーンが整然とインデントされ、一貫性があります。


27-30: Moshi ビルダーのインデント統一
.add(KotlinJsonAdapterFactory()).build() のチェーンが適切に揃えられています。


32-38: Retrofit ビルダーのメソッドチェーン整形
.baseUrl.create の一連のチェーンが見やすく配置され、改行・インデントが統一されています。


42-49: レスポンス処理部のインデント調整
if (response.isSuccessful) ブロック内のインデントと改行位置が整理され、可読性が向上しています。


56-56: インデントのみの変更であり、追加コメントは不要です。

app/src/main/java/net/harutiro/nationalweather/features/Weather/repositories/NationwideWeatherRepositoryImpl.kt (4)

17-18: コンストラクタ引数の末尾カンマと改行
デフォルト引数の後ろにトレーリングカンマが追加され、複数引数時の差分に強くなっています。


20-20: メソッドシグネチャの整形
override suspend fun getNationwideWeather のシグネチャが見やすく複数行に分割され、可読性が向上しています。


24-24: async 呼び出しのインデント統一
async { ... } のネストが適切にインデントされ、ビルド生成コードと一貫性があります。


34-37: getPrefectureWeather メソッド整形
シグネチャと閉じ波括弧の位置が整理され、他メソッドと同様のスタイルになっています。

app/build.gradle.kts (4)

30-30: proguardFiles リストの末尾カンマ追加
Kotlin DSL のリストで末尾カンマが揃えられ、差分が明確になりました。


55-64: lint.disable リストのインデント・改行統一
複数行リスト形式での記述が揃えられ、可読性と追記時の差分管理が容易です。


95-95: accompanist-swiperefresh 依存追加
Compose 用スワイプリフレッシュのライブラリ依存が新たに追加され、機能拡張が可能になります。


107-107: テスト用 Kotlin DSL 依存追加
kotlin("test") のテスト実装依存を追加し、ユニットテスト環境が整備されました。

app/src/main/java/net/harutiro/nationalweather/core/presenter/home/page/NationwideWeatherCell.kt (7)

45-48: modifier プロパティのマルチライン化
Modifier.widthModifier.height のチェーンが縦並びになり、可読性が向上しています。


83-88: ImageLoader.Builder 部分のインデント統一
SVG デコーダ設定のビルダーが整然とインデントされ、ブロックの範囲が明確です。


108-114: TextStyle(上部気温)の整形
fontSize などのプロパティが複数行で揃えられ、スタイル設定が読みやすくなっています。


118-124: TextStyle(下部気温)の整形
上と同様に、色や行間の指定が複数行に分割され、一貫性があります。


130-130: NationwideWeatherCityName シグネチャの単一行化
パラメータが一つの関数は単一行でまとめられ、シンプルになっています。


142-144: プレビューの modifier マルチライン化
Modifier.padding の行が整形され、プレビュー設定が見やすくなりました。


154-154: プレビューログ呼び出しの整形
Timber.tag(...).d(...) のラムダ内インデントが揃えられています。

app/src/main/java/net/harutiro/nationalweather/core/presenter/home/page/HomePage.kt (4)

22-25: HomePage シグネチャのマルチライン化
ラムダ引数とデフォルト viewModel パラメータが複数行で整形され、可読性が向上しています。


26-26: LaunchedEffect キー指定の整形
key1 = viewModel.weathers 部分が統一的に整形され、他の LaunchedEffect と一貫性があります。


38-41: LazyVerticalGridmodifier マルチライン化
Modifier.padding(padding) 部分が縦並びになり、引数構造が把握しやすいです。


50-51: goDetail ラムダ内の整形
Log.dtoDetail の呼び出しが適切にインデント・改行され、視認性が向上しています。

app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoritePage.kt (7)

44-46: フォーマットが統一され、可読性が向上しています。

Scaffoldコンポーネントとそのラムダパラメータに末尾カンマが追加され、Kotlinの推奨スタイルに適合しています。この変更はコード全体の一貫性を高めています。


52-54: モディファイアのフォーマットが改善されました。

modifierの記述が明示的な代入構文と適切な改行を使用するように変更され、より読みやすくなっています。この形式はコードベース全体で一貫していて良いです。


58-59: キーラムダに末尾カンマが追加されました。

items関数のkeyパラメータに末尾カンマが追加され、一貫したスタイルになっています。これは将来的にパラメータを追加する際にも有用です。


74-74: クリックハンドラのラムダに末尾カンマが追加されました。

favoriteOnClickパラメータに末尾カンマが追加され、コードの一貫性が向上しています。


83-83: 配置パラメータの末尾カンマが追加されました。

verticalArrangementパラメータに末尾カンマが追加され、他のパラメータとスタイルが統一されています。


92-92: テキストコンポーネントのフォーマットが改善されました。

textプロパティに末尾カンマが追加され、一貫したフォーマットスタイルになっています。


98-98: 関数終了時の改行が追加されました。

FavoritePage関数の終了ブレースの後に改行が追加され、ファイル終端に改行を含める標準的なコーディング規約に準拠しています。

app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepositoryImpl.kt (5)

14-15: コンストラクタパラメータに末尾カンマが追加されました。

コンストラクタパラメータに末尾カンマが追加され、Kotlinのベストプラクティスに沿った形式になっています。将来的にパラメータを追加する際にも変更が最小限で済みます。


17-17: メソッド宣言とフロー制御のフォーマットが改善されました。

insertFavoriteメソッドの宣言と条件付きフロー(run ブロック)のフォーマットが調整され、一貫性のあるインデントとスペーシングになっています。

Also applies to: 22-22


24-31: エンティティ初期化のフォーマットが改善されました。

WeatherFavoriteEntityのインスタンス生成が明示的な代入構文と末尾カンマを使用するように変更され、より読みやすく一貫性のあるコードになっています。


38-38: メソッド宣言とフロー制御のフォーマットが統一されました。

deleteFavoriteメソッドの宣言と条件付きフロー(run ブロック)のフォーマットが調整され、insertFavoriteメソッドと同様のスタイルになっています。コード全体の一貫性が向上しています。

Also applies to: 44-44


64-64: ファイル終端に改行が追加されました。

ファイル終端に改行が追加され、標準的なコーディング規約に準拠しています。これはバージョン管理システムでの差分表示も改善します。

app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoriteWeatherCell.kt (13)

49-52: 関数パラメータのフォーマットが改善されました。

PrefectureFavoriteWeatherCell関数のパラメータリストに末尾カンマが追加され、Kotlinのベストプラクティスに沿った形式になっています。


53-61: ElevatedCardコンポーネントのフォーマットが改善されました。

ElevatedCardコンポーネントのパラメータが明示的な代入構文と末尾カンマを使用するように変更され、より読みやすく一貫性のあるコードになっています。


63-67: Columnコンポーネントのモディファイアフォーマットが改善されました。

Columnコンポーネントのmodifierが明示的な代入構文と適切な改行を使用するように変更され、より読みやすくなっています。


72-78: TextStyleのフォーマットが改善されました。

TextStyleの定義が明示的な代入構文と末尾カンマを使用するように変更され、より読みやすく一貫性のあるコードになっています。


89-89: for文のフォーマットが改善されました。

forループのフォーマットが整えられ、コードの一貫性が向上しています。


111-116: Boxコンポーネントのモディファイアフォーマットが改善されました。

Boxコンポーネントのmodifierが明示的な代入構文と適切な改行を使用するように変更され、より読みやすくなっています。


125-130: WeatherImageコンポーネントのモディファイアフォーマットが改善されました。

WeatherImageコンポーネントのモディファイアが明示的な代入構文と適切な改行を使用するように変更され、より読みやすくなっています。


132-135: Columnコンポーネントのフォーマットが改善されました。

Columnコンポーネントのフォーマットが整えられ、末尾カンマが追加されています。


157-162: ImageLoaderのビルダーフォーマットが改善されました。

ImageLoaderの構築が明示的な代入構文と適切な改行を使用するように変更され、ビルダーパターンの可読性が向上しています。


181-188: TextStyleのフォーマットが一貫して改善されました。

温度表示用のTextStyleが明示的な代入構文と末尾カンマを使用するように変更され、コード全体で一貫したフォーマットになっています。

Also applies to: 191-198


206-212: WeatherDateコンポーネントのTextStyleフォーマットが改善されました。

WeatherDateコンポーネント内のTextStyleが他のスタイル定義と同様のフォーマットになり、コードの一貫性が向上しています。


232-305: プレビュー用のサンプルデータフォーマットが大幅に改善されました。

プレビュー用のWeatherインスタンス作成が明示的な代入構文と末尾カンマを使用するように変更され、複雑なネストされたデータ構造の可読性が大幅に向上しています。適切なインデントと改行により、各レベルの階層が視覚的に明確になっています。


310-310: LazyVerticalGridのモディファイアフォーマットが改善されました。

LazyVerticalGridmodifierパラメータの直接代入スタイルが整えられ、コードの一貫性が向上しています。

app/src/main/java/net/harutiro/nationalweather/core/router/Router.kt (10)

17-18: インポート文が整理されました。

インポート文の順序が整理され、使用されていないインポートが削除されました。これによりコードの可読性が向上し、不要な依存関係が削除されています。

Also applies to: 26-26, 29-30, 32-32


40-41: コンストラクタパラメータに末尾カンマが追加されました。

Router関数のパラメータリストに末尾カンマが追加され、Kotlinのベストプラクティスに沿った形式になっています。将来的にパラメータを追加する際にも変更が最小限で済みます。


44-62: ナビゲーションアイテムリストのフォーマットが大幅に改善されました。

bottomNavigationItemsの初期化が明示的な代入構文と末尾カンマを使用するように変更され、各項目のパラメータが整理されています。これにより複雑なデータ構造の可読性が大幅に向上しています。


65-65: 条件文のフォーマットが改善されました。

if文のフォーマットが整えられ、コードの一貫性が向上しています。


84-84: パラメータとラムダに末尾カンマが追加されました。

selectedItemIndexパラメータとbottomBarラムダに末尾カンマが追加され、コード全体の一貫性が向上しています。

Also applies to: 89-89


94-97: NavHostのモディファイアフォーマットが改善されました。

NavHostコンポーネントのmodifierが明示的な代入構文と適切な改行を使用するように変更され、より読みやすくなっています。


104-104: ラムダ終了部に末尾カンマが追加されました。

toDetailラムダの終了部に末尾カンマが追加され、コードスタイルの一貫性が向上しています。


112-118: ナビゲーション引数とCityId変換のフォーマットが改善されました。

ナビゲーション引数のリストとcityIdの変換ロジックのフォーマットが改善され、明示的な代入構文と適切な改行を使用するようになりました。これにより複雑なコードブロックの可読性が向上しています。


123-123: ラムダとif-else文のフォーマットが改善されました。

toBottomNavigationBarラムダの終了部とif-else文の始まりに末尾カンマが追加され、コードスタイルの一貫性が向上しています。

Also applies to: 125-125


136-136: 列挙型に末尾カンマが追加されました。

BottomNavigationBarRoute列挙型の最後のエントリDETAILに末尾カンマが追加され、Kotlinのベストプラクティスに沿った形式になっています。将来的に列挙型に新しい値を追加する際にも変更が最小限で済みます。

app/src/main/java/net/harutiro/nationalweather/core/presenter/BottomNavigationBar.kt (6)

24-28: 末尾カンマの追加によるパラメータリストの整形
BottomNavigationBar の関数シグネチャに末尾カンマが追加され、一貫したフォーマットになっています。


32-44: Composable 呼び出し時の末尾カンマ整備
NavigationBarItem 内の BadgeIcon 呼び出しでパラメータリストに末尾カンマが追加され、可読性と差分の扱いやすさが向上しています。


52-60: 末尾カンマの追加による内部関数シグネチャの整形
BadgeIcon の関数シグネチャに末尾カンマが追加され、引数リストが整然と揃っています。


61-74: Badge ラムダ引数での末尾カンマ整備
BadgedBox のラムダ引数の閉じ括弧に末尾カンマが追加され、整形ルールが統一されています。


75-80: Icon 呼び出しでの末尾カンマ整備
Icon コンポーザブルの引数リストにも末尾カンマが追加され、一貫性が保たれています。


82-110: プレビュー関数の多行リストとアイテム追加
GreetingPreviewBottomNavigationBar 呼び出し時の items リストが多行で書かれ、トレーリングカンマも整備されています。さらにプレビュー用に "favorite" アイテムが追加され、UI 一貫性の確認が向上しています。

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApiImpl.kt (1)

34-35: APIのベースURLを定数または設定から取得することを検討してください

APIのベースURLがハードコードされていますが、これは環境によって変更が必要になる可能性があります。BuildConfigやリソースファイル、または依存性注入を使用して外部から設定できるようにすることを検討してください。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9b52f3 and 6e0a8be.

📒 Files selected for processing (24)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/page/DetailPage.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/viewModel/DetailViewModel.kt (3 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoritePage.kt (4 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoriteWeatherCell.kt (7 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/viewModel/FavoriteViewModel.kt (3 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/home/page/HomePage.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/home/viewModel/HomeViewModel.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/router/Router.kt (3 hunks)
  • app/src/main/java/net/harutiro/nationalweather/core/utils/room/typeConverter/CityIdConverter.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/apis/NationwideWeatherApi.kt (0 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/entities/CityId.kt (0 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteApi.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteApiImpl.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteDao.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/entities/WeatherFavoriteEntity.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepository.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepositoryImpl.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApi.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApiBuilderInterface.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApiImpl.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/entities/CityId.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/entities/Weather.kt (2 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/repositories/NationwideWeatherRepository.kt (1 hunks)
  • app/src/main/java/net/harutiro/nationalweather/features/weather/repositories/NationwideWeatherRepositoryImpl.kt (2 hunks)
💤 Files with no reviewable changes (2)
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/entities/CityId.kt
  • app/src/main/java/net/harutiro/nationalweather/features/Weather/apis/NationwideWeatherApi.kt
✅ Files skipped from review due to trivial changes (7)
  • app/src/main/java/net/harutiro/nationalweather/core/utils/room/typeConverter/CityIdConverter.kt
  • app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApiBuilderInterface.kt
  • app/src/main/java/net/harutiro/nationalweather/features/weather/repositories/NationwideWeatherRepositoryImpl.kt
  • app/src/main/java/net/harutiro/nationalweather/features/weather/entities/Weather.kt
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteDao.kt
  • app/src/main/java/net/harutiro/nationalweather/features/weather/entities/CityId.kt
  • app/src/main/java/net/harutiro/nationalweather/features/weather/repositories/NationwideWeatherRepository.kt
🚧 Files skipped from review as they are similar to previous changes (13)
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteApi.kt
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepository.kt
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/apis/WeatherFavoriteApiImpl.kt
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/page/DetailPage.kt
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/viewModel/FavoriteViewModel.kt
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/detail/viewModel/DetailViewModel.kt
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoritePage.kt
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/entities/WeatherFavoriteEntity.kt
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/home/viewModel/HomeViewModel.kt
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/favorite/page/FavoriteWeatherCell.kt
  • app/src/main/java/net/harutiro/nationalweather/core/router/Router.kt
  • app/src/main/java/net/harutiro/nationalweather/core/presenter/home/page/HomePage.kt
  • app/src/main/java/net/harutiro/nationalweather/features/favoriteDB/repositories/WeatherFavoriteRepositoryImpl.kt
🔇 Additional comments (2)
app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApi.kt (1)

1-8: インターフェースの設計が適切です!

シンプルで明確なインターフェース設計になっています。suspendキーワードを使用して非同期処理を適切に実装しており、良い設計です。

app/src/main/java/net/harutiro/nationalweather/features/weather/apis/NationwideWeatherApiImpl.kt (1)

45-45: ミュータブル操作の注意点

レスポンスボディを直接変更していますが、これはAPIから返されたオブジェクトが変更可能であることを前提としています。イミュータブルな設計を考慮する場合は、新しいオブジェクトを作成する方が安全です。

Comment on lines 42 to 50
return if (response.isSuccessful) {
Timber.tag("OkHttp").d(response.body().toString())
val weather = response.body()
weather?.cityId = cityId
weather ?: Weather(listOf(), "", CityId.TOKYO)
} else {
Timber.tag("OkHttp").d(response.errorBody().toString())
Weather(listOf(), "", CityId.TOKYO)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

エラーハンドリングの改善を検討してください

現在のコードでは、APIリクエストが失敗した場合にデフォルトのTOKYOの天気データを返していますが、これはエラーを適切に処理していません。Result型を使用するか、エラー情報を含むシールドクラスを返すことで、呼び出し元がエラーを適切に処理できるようにすることを検討してください。

-    return if (response.isSuccessful) {
-        Timber.tag("OkHttp").d(response.body().toString())
-        val weather = response.body()
-        weather?.cityId = cityId
-        weather ?: Weather(listOf(), "", CityId.TOKYO)
-    } else {
-        Timber.tag("OkHttp").d(response.errorBody().toString())
-        Weather(listOf(), "", CityId.TOKYO)
-    }
+    return if (response.isSuccessful) {
+        Timber.tag("OkHttp").d(response.body().toString())
+        val weather = response.body()
+        if (weather != null) {
+            weather.cityId = cityId
+            weather
+        } else {
+            Timber.tag("OkHttp").e("Response body is null")
+            Weather(listOf(), "データの取得に失敗しました", CityId.TOKYO)
+        }
+    } else {
+        Timber.tag("OkHttp").e("API request failed: ${response.code()} - ${response.errorBody()?.string()}")
+        Weather(listOf(), "API接続エラー: ${response.code()}", CityId.TOKYO)
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return if (response.isSuccessful) {
Timber.tag("OkHttp").d(response.body().toString())
val weather = response.body()
weather?.cityId = cityId
weather ?: Weather(listOf(), "", CityId.TOKYO)
} else {
Timber.tag("OkHttp").d(response.errorBody().toString())
Weather(listOf(), "", CityId.TOKYO)
}
return if (response.isSuccessful) {
Timber.tag("OkHttp").d(response.body().toString())
val weather = response.body()
if (weather != null) {
weather.cityId = cityId
weather
} else {
Timber.tag("OkHttp").e("Response body is null")
Weather(listOf(), "データの取得に失敗しました", CityId.TOKYO)
}
} else {
Timber.tag("OkHttp").e("API request failed: ${response.code()} - ${response.errorBody()?.string()}")
Weather(listOf(), "API接続エラー: ${response.code()}", CityId.TOKYO)
}

@harutiro harutiro merged commit cb0eb34 into develop Apr 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants