Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/commands/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ pub enum CommentsCommand {
order: Option<String>,

/// Sort ascending instead of descending
#[arg(long)]
#[arg(long, conflicts_with = "descending")]
ascending: bool,

/// Sort descending (explicit counterpart to --ascending)
#[arg(long, conflicts_with = "ascending")]
descending: bool,
},

/// Get a comment by ID
Expand All @@ -70,8 +74,12 @@ pub enum CommentsCommand {
order: Option<String>,

/// Sort ascending instead of descending
#[arg(long)]
#[arg(long, conflicts_with = "descending")]
ascending: bool,

/// Sort descending (explicit counterpart to --ascending)
#[arg(long, conflicts_with = "ascending")]
descending: bool,
},
}

Expand Down Expand Up @@ -105,14 +113,15 @@ pub async fn execute(
offset,
order,
ascending,
descending,
} => {
let request = CommentsRequest::builder()
.parent_entity_type(ParentEntityType::from(entity_type))
.parent_entity_id(entity_id)
.limit(limit)
.maybe_offset(offset)
.maybe_order(order)
.ascending(ascending)
.ascending(if descending { false } else { ascending })
.build();

let comments = client.comments(&request).await?;
Expand All @@ -136,13 +145,14 @@ pub async fn execute(
offset,
order,
ascending,
descending,
} => {
let request = CommentsByUserAddressRequest::builder()
.user_address(address)
.limit(limit)
.maybe_offset(offset)
.maybe_order(order)
.ascending(ascending)
.ascending(if descending { false } else { ascending })
.build();

let comments = client.comments_by_user_address(&request).await?;
Expand Down
9 changes: 7 additions & 2 deletions src/commands/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ pub enum EventsCommand {
order: Option<String>,

/// Sort ascending instead of descending
#[arg(long)]
#[arg(long, conflicts_with = "descending")]
ascending: bool,

/// Sort descending (explicit counterpart to --ascending)
#[arg(long, conflicts_with = "ascending")]
descending: bool,

/// Filter by tag slug (e.g. "politics", "crypto")
#[arg(long)]
tag: Option<String>,
Expand Down Expand Up @@ -71,6 +75,7 @@ pub async fn execute(client: &gamma::Client, args: EventsArgs, output: OutputFor
offset,
order,
ascending,
descending,
tag,
} => {
let resolved_closed = closed.or_else(|| active.map(|a| !a));
Expand All @@ -79,7 +84,7 @@ pub async fn execute(client: &gamma::Client, args: EventsArgs, output: OutputFor
.limit(limit)
.maybe_closed(resolved_closed)
.maybe_offset(offset)
.ascending(ascending)
.ascending(if descending { false } else { ascending })
.maybe_tag_slug(tag)
// EventsRequest::order is Vec<String>; into_iter on Option yields 0 or 1 items.
.order(order.into_iter().collect())
Expand Down
9 changes: 7 additions & 2 deletions src/commands/markets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ pub enum MarketsCommand {
order: Option<String>,

/// Sort ascending instead of descending
#[arg(long)]
#[arg(long, conflicts_with = "descending")]
ascending: bool,

/// Sort descending (explicit counterpart to --ascending)
#[arg(long, conflicts_with = "ascending")]
descending: bool,
},

/// Get a single market by ID or slug
Expand Down Expand Up @@ -87,6 +91,7 @@ pub async fn execute(
offset,
order,
ascending,
descending,
} => {
let resolved_closed = closed.or_else(|| active.map(|a| !a));

Expand All @@ -95,7 +100,7 @@ pub async fn execute(
.maybe_closed(resolved_closed)
.maybe_offset(offset)
.maybe_order(order)
.ascending(ascending)
.ascending(if descending { false } else { ascending })
Copy link

Choose a reason for hiding this comment

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

Redundant conditional — descending variable has no effect

Low Severity

The expression if descending { false } else { ascending } is equivalent to just ascending in all valid input states, because the conflicts_with constraint guarantees descending and ascending can never both be true. When descending is true, ascending is already false, so the explicit false branch is redundant. The descending variable appears to influence behavior but never does, which is misleading. This pattern is repeated across all six call sites.

Additional Locations (2)
Fix in Cursor Fix in Web

.build();

let markets = client.markets(&request).await?;
Expand Down
9 changes: 7 additions & 2 deletions src/commands/series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ pub enum SeriesCommand {
order: Option<String>,

/// Sort ascending instead of descending
#[arg(long)]
#[arg(long, conflicts_with = "descending")]
ascending: bool,

/// Sort descending (explicit counterpart to --ascending)
#[arg(long, conflicts_with = "ascending")]
descending: bool,

/// Filter by closed status
#[arg(long)]
closed: Option<bool>,
Expand All @@ -53,13 +57,14 @@ pub async fn execute(client: &gamma::Client, args: SeriesArgs, output: OutputFor
offset,
order,
ascending,
descending,
closed,
} => {
let request = SeriesListRequest::builder()
.limit(limit)
.maybe_offset(offset)
.maybe_order(order)
.ascending(ascending)
.ascending(if descending { false } else { ascending })
.maybe_closed(closed)
.build();

Expand Down
9 changes: 7 additions & 2 deletions src/commands/sports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ pub enum SportsCommand {
order: Option<String>,

/// Sort ascending instead of descending
#[arg(long)]
#[arg(long, conflicts_with = "descending")]
ascending: bool,

/// Sort descending (explicit counterpart to --ascending)
#[arg(long, conflicts_with = "ascending")]
descending: bool,

/// Filter by league
#[arg(long)]
league: Option<String>,
Expand All @@ -60,13 +64,14 @@ pub async fn execute(client: &gamma::Client, args: SportsArgs, output: OutputFor
offset,
order,
ascending,
descending,
league,
} => {
let request = TeamsRequest::builder()
.limit(limit)
.maybe_offset(offset)
.maybe_order(order)
.ascending(ascending)
.ascending(if descending { false } else { ascending })
.league(league.into_iter().collect())
.build();

Expand Down
9 changes: 7 additions & 2 deletions src/commands/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ pub enum TagsCommand {
offset: Option<i32>,

/// Sort ascending instead of descending
#[arg(long)]
#[arg(long, conflicts_with = "descending")]
ascending: bool,

/// Sort descending (explicit counterpart to --ascending)
#[arg(long, conflicts_with = "ascending")]
descending: bool,
},

/// Get a single tag by ID or slug
Expand Down Expand Up @@ -68,11 +72,12 @@ pub async fn execute(client: &gamma::Client, args: TagsArgs, output: OutputForma
limit,
offset,
ascending,
descending,
} => {
let request = TagsRequest::builder()
.limit(limit)
.maybe_offset(offset)
.ascending(ascending)
.ascending(if descending { false } else { ascending })
.build();

let tags = client.tags(&request).await?;
Expand Down