mirror of
https://github.com/gmbrax/MediaManager-core.git
synced 2026-11-09 22:10:17 +00:00
Compare commits
18
Commits
9aadb7283c
...
master
@@ -0,0 +1,100 @@
|
||||
name: Qodana
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target_ref:
|
||||
description: 'Branch, tag, or commit SHA to analyze (default: develop)'
|
||||
required: false
|
||||
default: 'develop'
|
||||
type: string
|
||||
pull_request:
|
||||
push:
|
||||
branches: # Specify your branches here
|
||||
- master
|
||||
- main # The 'main' branch
|
||||
- develop
|
||||
- 'releases/*' # The release branches
|
||||
|
||||
jobs:
|
||||
qodana:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
checks: write
|
||||
steps:
|
||||
# Checkout for pull_request events: use the PR head SHA for accurate analysis
|
||||
- name: Checkout (pull_request)
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0 # a full history is required for pull request analysis
|
||||
|
||||
# Checkout for manual runs: use the selected branch/ref (default: develop)
|
||||
- name: Checkout (workflow_dispatch)
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.target_ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
# Checkout for push events (e.g., merges to develop): use the current commit
|
||||
- name: Checkout (push)
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Set up JDK for potential code generation (e.g., protobuf) prior to Qodana analysis
|
||||
- name: Set up Java 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: 'maven'
|
||||
|
||||
# Generate sources so that Qodana resolves imports from generated code
|
||||
- name: Generate sources (protobuf)
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -f ./mvnw ]; then chmod +x ./mvnw || true; fi
|
||||
if [ -x ./mvnw ]; then
|
||||
./mvnw -B -DskipTests -DskipITs=true generate-sources || true
|
||||
elif command -v mvn >/dev/null 2>&1; then
|
||||
mvn -B -DskipTests -DskipITs=true generate-sources || true
|
||||
else
|
||||
echo "[Qodana prep] Maven not available; skipping generate-sources"
|
||||
fi
|
||||
|
||||
# Optionally compile (skip tests) to ensure classes are available for resolution
|
||||
- name: Compile (skip tests)
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -x ./mvnw ]; then
|
||||
./mvnw -B -DskipTests -DskipITs=true compile || true
|
||||
elif command -v mvn >/dev/null 2>&1; then
|
||||
mvn -B -DskipTests -DskipITs=true compile || true
|
||||
else
|
||||
echo "[Qodana prep] Maven not available; skipping compile"
|
||||
fi
|
||||
|
||||
# Helpful debug: list generated sources if present
|
||||
- name: Show generated sources
|
||||
shell: bash
|
||||
run: |
|
||||
echo "=== target/generated-sources (tree) ===" || true
|
||||
if [ -d target/generated-sources ]; then
|
||||
find target/generated-sources -maxdepth 3 -type d -print || true
|
||||
else
|
||||
echo "(none)" || true
|
||||
fi
|
||||
- name: 'Qodana Scan'
|
||||
uses: JetBrains/qodana-action@v2025.2
|
||||
with:
|
||||
# Enable PR-specific reporting only for pull_request events
|
||||
pr-mode: ${{ github.event_name == 'pull_request' }}
|
||||
# No extra args needed; linter is defined in qodana.yaml (qodana-jvm)
|
||||
env:
|
||||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_268690425 }}
|
||||
QODANA_ENDPOINT: 'https://qodana.cloud'
|
||||
@@ -0,0 +1,5 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
This project adheres to No Code of Conduct. We are all adults. We accept anyone's contributions. Nothing else matters.
|
||||
|
||||
For more information please visit the [No Code of Conduct](https://nocodeofconduct.com) homepage.
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
# Refactoring History—MediaManager Core
|
||||
|
||||
This document records the refactorings applied during development.
|
||||
|
||||
## Refactoring #1: Connection Pool Implementation
|
||||
|
||||
**Date**: 2025-11-13
|
||||
**Commits**: ```22476abb27d95e88ae0439d97ef97467b6a4f985```
|
||||
|
||||
### Problem Identified
|
||||
- Database connections were created multiple times
|
||||
- No centralized control
|
||||
- Possible resource leaks
|
||||
|
||||
### Technique Applied
|
||||
- **Pattern**: Singleton Pattern
|
||||
- **Refactoring**: Extract Class + Introduce Singleton
|
||||
|
||||
### Solution
|
||||
Created `DatabaseManager` class that:
|
||||
- Maintains single instance (Singleton)
|
||||
- Manages connection pool
|
||||
- Provides centralized `getConnection()` method
|
||||
|
||||
### Result
|
||||
- ✅ Single reusable connection
|
||||
- ✅ Code centralized in one class
|
||||
- ✅ Thread-safe
|
||||
- ✅ Easier to test
|
||||
|
||||
### Extracted Component
|
||||
`DatabaseManager` - available in `mediamanager-components`
|
||||
|
||||
---
|
||||
|
||||
## Refactoring #2: Thread Pool for IPC
|
||||
|
||||
**Date**: 2025-11-14
|
||||
**Commits**: ```f1071dca03da33f7355a6927497509b5aedaa4a2```
|
||||
|
||||
### Problem Identified
|
||||
- New thread created for each IPC client
|
||||
- Doesn't scale well
|
||||
- Thread creation overhead
|
||||
|
||||
### Technique Applied
|
||||
- **Pattern**: Thread Pool Pattern
|
||||
- **Refactoring**: Replace Thread Creation with Thread Pool
|
||||
|
||||
### Solution
|
||||
Implemented `ExecutorService` with:
|
||||
- Fixed thread pool
|
||||
- Thread reuse
|
||||
- Ordered shutdown
|
||||
|
||||
### Result
|
||||
- ✅ Better performance
|
||||
- ✅ Controlled resource usage
|
||||
- ✅ Scalability
|
||||
|
||||
### Extracted Component
|
||||
`IPCServer` - available in `mediamanager-components`
|
||||
|
||||
---
|
||||
|
||||
## Refactoring #3: Graceful Shutdown
|
||||
|
||||
**Date**: 2025-11-13
|
||||
**Commits**: ```65e14930076db71a312feae373d6c5daee3c4d29```,```b7ff9d1e16c85bf986a770676827bee390f0d53c```
|
||||
|
||||
### Problem Identified
|
||||
- Resources weren't released on exit
|
||||
- Database connections remained open
|
||||
- Thread pool didn't terminate correctly
|
||||
|
||||
### Technique Applied
|
||||
- **Pattern**: Shutdown Hook Pattern
|
||||
- **Refactoring**: Introduce Shutdown Protocol
|
||||
|
||||
### Solution
|
||||
Implemented shutdown hooks that:
|
||||
- Close database connections
|
||||
- Terminate thread pools
|
||||
- Release sockets
|
||||
- In specific order with timeouts
|
||||
|
||||
### Result
|
||||
- ✅ Ordered cleanup
|
||||
- ✅ No resource leaks
|
||||
- ✅ Shutdown logging
|
||||
- ✅ Timeout to prevent hanging
|
||||
|
||||
### Extracted Component
|
||||
Logic incorporated in `DatabaseManager` and `IPCServer`
|
||||
|
||||
---
|
||||
|
||||
## Applied Principles
|
||||
|
||||
- **DRY** (Don't Repeat Yourself): Elimination of duplicated code
|
||||
- **SOLID**: Especially Single Responsibility Principle
|
||||
- **Design Patterns**: Singleton, Thread Pool, Shutdown Hook
|
||||
- **Clean Code**: Clear names, small methods, well-defined responsibilities
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
####################################################################################################################
|
||||
# WARNING: Do not store sensitive information in this file, as its contents will be included in the Qodana report. #
|
||||
####################################################################################################################
|
||||
|
||||
version: "1.0"
|
||||
# Use canonical linter name to avoid image warnings and CLI flag issues
|
||||
linter: qodana-jvm
|
||||
profile:
|
||||
name: qodana.recommended
|
||||
bootstrap: |
|
||||
# Disabled bootstrap to avoid shell parsing issues in CI. If you need code generation,
|
||||
# we can re-enable a robust script later. For now, do nothing and let Qodana run.
|
||||
:
|
||||
include:
|
||||
- name: CheckDependencyLicenses
|
||||
exclude:
|
||||
# Exclude generated sources from inspections to reduce noise
|
||||
- name: All
|
||||
paths:
|
||||
- target/protoc-dependencies/**
|
||||
# Keep generated sources included for indexing/resolution; excluding them can cause unresolved imports
|
||||
Reference in New Issue
Block a user