Skip to content

Commit 76f86b9

Browse files
committed
fix: Address quality check issues
- Remove unused variable in conference green flags function - Fix OpenAlex test with realistic mock data for new scoring algorithm - Remove debug files without SPDX headers - Format code with ruff
1 parent 70290c6 commit 76f86b9

File tree

5 files changed

+51951
-7
lines changed

5 files changed

+51951
-7
lines changed

scripts/post-pr-merge.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
# Post-PR merge cleanup script
3+
# Run this after successfully merging a PR to clean up local branches and update main
4+
# Usage: ./scripts/post-pr-merge.sh [branch-name]
5+
# If branch-name is not provided, will use the current branch
6+
7+
set -e # Exit on first error
8+
9+
# Color codes for output
10+
RED='\033[0;31m'
11+
GREEN='\033[0;32m'
12+
YELLOW='\033[1;33m'
13+
BLUE='\033[0;34m'
14+
NC='\033[0m' # No Color
15+
16+
echo -e "${BLUE}========================================${NC}"
17+
echo -e "${BLUE}Post-PR Merge Cleanup${NC}"
18+
echo -e "${BLUE}========================================${NC}"
19+
echo ""
20+
21+
# Get the branch name to delete
22+
BRANCH_TO_DELETE=""
23+
if [ -n "$1" ]; then
24+
BRANCH_TO_DELETE="$1"
25+
else
26+
# Get current branch name
27+
BRANCH_TO_DELETE=$(git branch --show-current)
28+
fi
29+
30+
# Safety check: don't delete main or develop branches
31+
if [ "$BRANCH_TO_DELETE" = "main" ] || [ "$BRANCH_TO_DELETE" = "develop" ]; then
32+
echo -e "${RED}✗ Error: Cannot delete main or develop branch${NC}"
33+
echo -e "${YELLOW} Please checkout a feature branch first${NC}"
34+
exit 1
35+
fi
36+
37+
echo -e "${YELLOW}Branch to delete: ${BRANCH_TO_DELETE}${NC}"
38+
echo ""
39+
40+
# Check if we're on the branch to be deleted
41+
CURRENT_BRANCH=$(git branch --show-current)
42+
if [ "$CURRENT_BRANCH" = "$BRANCH_TO_DELETE" ]; then
43+
# Switch to main branch
44+
echo -e "${YELLOW}▶ Checking out main branch...${NC}"
45+
git checkout main
46+
echo -e "${GREEN}✓ Switched to main${NC}"
47+
echo ""
48+
fi
49+
50+
# Pull latest changes from remote
51+
echo -e "${YELLOW}▶ Pulling latest changes from remote...${NC}"
52+
git pull origin main
53+
echo -e "${GREEN}✓ Main branch updated${NC}"
54+
echo ""
55+
56+
# Delete local branch
57+
echo -e "${YELLOW}▶ Deleting local branch: ${BRANCH_TO_DELETE}${NC}"
58+
if git branch -d "$BRANCH_TO_DELETE" 2>/dev/null; then
59+
echo -e "${GREEN}✓ Local branch deleted${NC}"
60+
else
61+
# If -d fails, try -D (force delete)
62+
echo -e "${YELLOW} Branch has unmerged changes, using force delete...${NC}"
63+
git branch -D "$BRANCH_TO_DELETE"
64+
echo -e "${GREEN}✓ Local branch force deleted${NC}"
65+
fi
66+
echo ""
67+
68+
# Delete remote branch if it exists
69+
echo -e "${YELLOW}▶ Checking for remote branch...${NC}"
70+
if git ls-remote --exit-code --heads origin "$BRANCH_TO_DELETE" >/dev/null 2>&1; then
71+
echo -e "${YELLOW} Deleting remote branch: ${BRANCH_TO_DELETE}${NC}"
72+
git push origin --delete "$BRANCH_TO_DELETE"
73+
echo -e "${GREEN}✓ Remote branch deleted${NC}"
74+
else
75+
echo -e "${BLUE} Remote branch already deleted${NC}"
76+
fi
77+
echo ""
78+
79+
# Prune remote tracking branches
80+
echo -e "${YELLOW}▶ Pruning stale remote tracking branches...${NC}"
81+
git fetch --prune
82+
echo -e "${GREEN}✓ Remote tracking branches pruned${NC}"
83+
echo ""
84+
85+
# Show current status
86+
echo -e "${BLUE}========================================${NC}"
87+
echo -e "${BLUE}Cleanup Complete${NC}"
88+
echo -e "${BLUE}========================================${NC}"
89+
echo ""
90+
echo -e "${GREEN}✓ Current branch: $(git branch --show-current)${NC}"
91+
echo -e "${GREEN}✓ Latest commit: $(git log -1 --oneline)${NC}"
92+
echo ""
93+
94+
# Show remaining local branches (excluding main and develop)
95+
echo -e "${BLUE}Remaining local branches:${NC}"
96+
git branch | grep -v "^\*" | grep -v "main" | grep -v "develop" || echo -e "${BLUE} (none)${NC}"
97+
echo ""
98+
99+
echo -e "${GREEN}✨ All done! Ready for the next feature.${NC}"

src/aletheia_probe/backends/openalex_analyzer.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ def _analyze_conference_patterns(
186186
"reasoning": self._generate_reasoning(red_flags, green_flags, metrics),
187187
}
188188

189-
def _calculate_base_metrics(
190-
self, openalex_data: dict[str, Any]
191-
) -> dict[str, Any]:
189+
def _calculate_base_metrics(self, openalex_data: dict[str, Any]) -> dict[str, Any]:
192190
"""Calculate base metrics shared by both journals and conferences.
193191
194192
Args:
@@ -384,7 +382,6 @@ def _check_conference_green_flags(self, metrics: dict[str, Any]) -> list[str]:
384382
green_flags = []
385383

386384
citation_ratio = metrics["citation_ratio"]
387-
years_active = metrics["years_active"]
388385
total_publications = metrics["total_publications"]
389386
total_citations = metrics["total_citations"]
390387
last_year = metrics["last_year"]
@@ -422,9 +419,7 @@ def _check_conference_green_flags(self, metrics: dict[str, Any]) -> list[str]:
422419

423420
# Recent activity (conferences may have gaps)
424421
if last_year and last_year >= current_year - 5:
425-
green_flags.append(
426-
f"Recently active: last publication in {last_year}"
427-
)
422+
green_flags.append(f"Recently active: last publication in {last_year}")
428423

429424
return green_flags
430425

tests/unit/test_openalex.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ async def test_get_source_by_name_success(self):
8787
"id": "https://openalex.org/S123456789",
8888
"display_name": "Journal of Computer Science",
8989
"issn_l": "1234-5678",
90+
"works_count": 1000,
91+
"cited_by_count": 50000,
92+
"first_publication_year": 2000,
93+
"last_publication_year": 2023,
94+
"type": "journal",
9095
}
9196
]
9297
}

0 commit comments

Comments
 (0)