All files / src/tools/generateReport reportBuilders.ts

100% Statements 22/22
100% Branches 24/24
100% Functions 12/12
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177                                  7x         7x 3x     7x                     6x                       6x                         3x                         5x 2x         3x 3x 3x 3x                     2x                     8x                         8x                         7x                     3x                         3x                         3x              
/**
 * Report section builders
 * 
 * ISMS Policy: SC-002 (Input Validation)
 */
 
import type { MEPDetails } from '../../types/europeanParliament.js';
import type { ReportSection } from './types.js';
 
/**
 * Create voting activity section
 * Cyclomatic complexity: 2
 */
export function createVotingSection(
  totalVotes: number, 
  mep: MEPDetails | null
): ReportSection {
  const section: ReportSection = {
    title: 'Voting Activity',
    content: `The MEP participated in ${String(totalVotes)} votes during this period.`
  };
  
  if (mep?.votingStatistics !== undefined) {
    section.data = { votingStatistics: mep.votingStatistics };
  }
  
  return section;
}
 
/**
 * Create committee involvement section
 * Cyclomatic complexity: 1
 */
export function createCommitteeSection(
  committeesLength: number, 
  mep: MEPDetails | null
): ReportSection {
  return {
    title: 'Committee Involvement',
    content: `Active member of ${String(committeesLength)} committees.`,
    data: { committees: mep?.committees }
  };
}
 
/**
 * Create parliamentary questions section with real data
 * Cyclomatic complexity: 1
 */
export function createParliamentaryQuestionsSection(questionsCount: number | null): ReportSection {
  return {
    title: 'Parliamentary Questions',
    content: questionsCount !== null
      ? `${String(questionsCount)} parliamentary questions found in EP Open Data (lower bound, first page).`
      : 'Parliamentary questions data not available from EP API.'
  };
}
 
/**
 * Create meeting activity section with real data
 * Cyclomatic complexity: 1
 */
export function createMeetingActivitySection(meetingsCount: number): ReportSection {
  return {
    title: 'Meeting Activity',
    content: meetingsCount > 0
      ? `${String(meetingsCount)} meetings recorded in EP Open Data during this period.`
      : 'Meeting count data not available from EP API for this filter.'
  };
}
 
/**
 * Create legislative output section with real data
 * Cyclomatic complexity: 1
 */
export function createLegislativeOutputSection(reportsCount: number | null, documentsCount: number | null): ReportSection {
  if (reportsCount === null && documentsCount === null) {
    return {
      title: 'Legislative Output',
      content: 'Legislative output data not available from EP API.'
    };
  }
  const parts: string[] = [];
  if (reportsCount !== null) parts.push(`${String(reportsCount)} adopted texts`);
  if (documentsCount !== null) parts.push(`${String(documentsCount)} committee documents`);
  return {
    title: 'Legislative Output',
    content: `${parts.join(' and ')} found in EP Open Data (parliament-wide lower bound, first page).`
  };
}
 
/**
 * Create member participation section
 * Cyclomatic complexity: 1
 */
export function createMemberParticipationSection(memberCount: number): ReportSection {
  return {
    title: 'Member Participation',
    content: `${String(memberCount)} members listed in EP Open Data. Attendance rate data not available from EP API.`
  };
}
 
/**
 * Create overall voting activity section with real data
 * Cyclomatic complexity: 1
 */
export function createOverallVotingSection(sessionCount: number | null): ReportSection {
  return {
    title: 'Overall Voting Activity',
    content: sessionCount !== null
      ? `${String(sessionCount)} plenary sessions found in EP Open Data for this period (lower bound, first page).`
      : 'Plenary session data not available from EP API.'
  };
}
 
/**
 * Create adoption rates section with real data
 * Cyclomatic complexity: 1
 */
export function createAdoptionRatesSection(adoptedCount: number | null): ReportSection {
  return {
    title: 'Adoption Rates',
    content: adoptedCount !== null
      ? `${String(adoptedCount)} adopted texts found in EP Open Data for this period (lower bound, first page).`
      : 'Adopted texts data not available from EP API.'
  };
}
 
/**
 * Create political group alignment section
 * Cyclomatic complexity: 1
 */
export function createPoliticalGroupSection(): ReportSection {
  return {
    title: 'Political Group Alignment',
    content: 'Political group voting alignment data can be analyzed via the compare_political_groups tool.'
  };
}
 
/**
 * Create new proposals section with real data
 * Cyclomatic complexity: 1
 */
export function createNewProposalsSection(procedureCount: number | null): ReportSection {
  return {
    title: 'New Proposals',
    content: procedureCount !== null
      ? `${String(procedureCount)} legislative procedures found in EP Open Data for this period (lower bound, first page).`
      : 'Legislative procedures data not available from EP API.'
  };
}
 
/**
 * Create completed procedures section with real data
 * Cyclomatic complexity: 1
 */
export function createCompletedProceduresSection(completedCount: number | null): ReportSection {
  return {
    title: 'Completed Procedures',
    content: completedCount !== null
      ? `${String(completedCount)} adopted texts recorded as completed in EP Open Data (lower bound, first page).`
      : 'Completed procedures data not available from EP API.'
  };
}
 
/**
 * Create ongoing procedures section with real data
 * Cyclomatic complexity: 1
 */
export function createOngoingProceduresSection(ongoingCount: number | null): ReportSection {
  return {
    title: 'Ongoing Procedures',
    content: ongoingCount !== null
      ? `${String(ongoingCount)} procedures estimated as ongoing (total procedures minus adopted texts, lower bound).`
      : 'Ongoing procedures data not available from EP API.'
  };
}