stack-performance
Version:
A comprehensive application stack analyzer that evaluates MEAN, MERN, and other Node.js-based applications across 15 performance criteria
119 lines (93 loc) • 4.21 kB
JavaScript
const BaseAnalyzer = require('./BaseAnalyzer');
/**
* Developer Productivity Analyzer with algorithmic scoring
*/
class DeveloperProductivityAnalyzer extends BaseAnalyzer {
constructor(stackInfo, projectPath) {
super(stackInfo, projectPath, 'Developer Productivity');
}
async analyze() {
const factors = [];
// Factor 1: Development Tools (40%)
const toolingScore = this.analyzeToolingSupport();
factors.push({ score: toolingScore, weight: 0.4 });
// Factor 2: Framework Learning Curve (30%)
const learningScore = this.analyzeLearningComplexity();
factors.push({ score: learningScore, weight: 0.3 });
// Factor 3: Documentation & Community (20%)
const communityScore = this.analyzeCommunitySupport();
factors.push({ score: communityScore, weight: 0.2 });
// Factor 4: Code Reusability (10%)
const reusabilityScore = this.analyzeCodeReusability();
factors.push({ score: reusabilityScore, weight: 0.1 });
const finalScore = this.calculateWeightedScore(factors);
const details = {
toolingSupport: toolingScore,
learningComplexity: learningScore,
communitySupport: communityScore,
codeReusability: reusabilityScore,
stackType: this.stackInfo.type,
analysisMethod: 'algorithmic',
factors: factors.map(f => ({ score: f.score, weight: f.weight }))
};
return this.createResult(finalScore, details, this.generateRecommendations(finalScore));
}
analyzeToolingSupport() {
let score = 60;
if (this.hasDependency('eslint')) score += 10;
if (this.hasDependency('prettier')) score += 8;
if (this.hasDependency('typescript')) score += 12;
if (this.hasDependency('nodemon')) score += 5;
if (this.hasDependency('jest')) score += 8;
if (this.hasDependency('mocha')) score += 6;
if (this.hasDependency('webpack')) score += 7;
if (this.hasDependency('vite')) score += 10;
return Math.min(100, score);
}
analyzeLearningComplexity() {
const { technologies } = this.stackInfo;
let score = 70;
if (technologies.includes('Express.js')) score += 15; // Simple and well-documented
if (technologies.includes('React')) score += 10; // Popular, good docs
if (technologies.includes('Angular')) score -= 5; // Steeper learning curve
if (technologies.includes('Vue.js')) score += 12; // Easy to learn
if (technologies.includes('Fastify')) score += 8; // Good docs, fast learning
return Math.min(100, score);
}
analyzeCommunitySupport() {
let score = 65;
const packageJson = this.stackInfo.packageJson;
if (packageJson && packageJson.dependencies) {
const depCount = Object.keys(packageJson.dependencies).length;
score += Math.min(20, depCount * 2); // More deps suggests active ecosystem
}
// Check for popular frameworks with strong communities
if (this.hasDependency('react')) score += 8;
if (this.hasDependency('express')) score += 8;
if (this.hasDependency('mongoose')) score += 5;
return Math.min(100, score);
}
analyzeCodeReusability() {
let score = 75; // Base score for Node.js modularity
// Check for modular patterns
const hasModules = this.findFiles('**/modules/**/*.js').length > 0 ||
this.findFiles('**/components/**/*.js').length > 0;
if (hasModules) score += 10;
// TypeScript enhances reusability
if (this.hasDependency('typescript')) score += 10;
return Math.min(100, score);
}
generateRecommendations(score) {
const recommendations = [];
if (score < 70) {
recommendations.push('Add development tools like ESLint and Prettier for better code quality');
recommendations.push('Consider using TypeScript for better developer experience');
}
if (score < 80) {
recommendations.push('Set up automated testing with Jest or Mocha');
recommendations.push('Add hot-reloading with nodemon for faster development');
}
return recommendations;
}
}
module.exports = DeveloperProductivityAnalyzer;