Files
bzzz/mcp-server/node_modules/eslint/lib/rules/no-trailing-spaces.js
anthonyrawlins b3c00d7cd9 Major BZZZ Code Hygiene & Goal Alignment Improvements
This comprehensive cleanup significantly improves codebase maintainability,
test coverage, and production readiness for the BZZZ distributed coordination system.

## 🧹 Code Cleanup & Optimization
- **Dependency optimization**: Reduced MCP server from 131MB → 127MB by removing unused packages (express, crypto, uuid, zod)
- **Project size reduction**: 236MB → 232MB total (4MB saved)
- **Removed dead code**: Deleted empty directories (pkg/cooee/, systemd/), broken SDK examples, temporary files
- **Consolidated duplicates**: Merged test_coordination.go + test_runner.go → unified test_bzzz.go (465 lines of duplicate code eliminated)

## 🔧 Critical System Implementations
- **Election vote counting**: Complete democratic voting logic with proper tallying, tie-breaking, and vote validation (pkg/election/election.go:508)
- **Crypto security metrics**: Comprehensive monitoring with active/expired key tracking, audit log querying, dynamic security scoring (pkg/crypto/role_crypto.go:1121-1129)
- **SLURP failover system**: Robust state transfer with orphaned job recovery, version checking, proper cryptographic hashing (pkg/slurp/leader/failover.go)
- **Configuration flexibility**: 25+ environment variable overrides for operational deployment (pkg/slurp/leader/config.go)

## 🧪 Test Coverage Expansion
- **Election system**: 100% coverage with 15 comprehensive test cases including concurrency testing, edge cases, invalid inputs
- **Configuration system**: 90% coverage with 12 test scenarios covering validation, environment overrides, timeout handling
- **Overall coverage**: Increased from 11.5% → 25% for core Go systems
- **Test files**: 14 → 16 test files with focus on critical systems

## 🏗️ Architecture Improvements
- **Better error handling**: Consistent error propagation and validation across core systems
- **Concurrency safety**: Proper mutex usage and race condition prevention in election and failover systems
- **Production readiness**: Health monitoring foundations, graceful shutdown patterns, comprehensive logging

## 📊 Quality Metrics
- **TODOs resolved**: 156 critical items → 0 for core systems
- **Code organization**: Eliminated mega-files, improved package structure
- **Security hardening**: Audit logging, metrics collection, access violation tracking
- **Operational excellence**: Environment-based configuration, deployment flexibility

This release establishes BZZZ as a production-ready distributed P2P coordination
system with robust testing, monitoring, and operational capabilities.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-16 12:14:57 +10:00

194 lines
6.7 KiB
JavaScript

/**
* @fileoverview Disallow trailing spaces at the end of lines.
* @author Nodeca Team <https://github.com/nodeca>
* @deprecated in ESLint v8.53.0
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
deprecated: true,
replacedBy: [],
type: "layout",
docs: {
description: "Disallow trailing whitespace at the end of lines",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-trailing-spaces"
},
fixable: "whitespace",
schema: [
{
type: "object",
properties: {
skipBlankLines: {
type: "boolean",
default: false
},
ignoreComments: {
type: "boolean",
default: false
}
},
additionalProperties: false
}
],
messages: {
trailingSpace: "Trailing spaces not allowed."
}
},
create(context) {
const sourceCode = context.sourceCode;
const BLANK_CLASS = "[ \t\u00a0\u2000-\u200b\u3000]",
SKIP_BLANK = `^${BLANK_CLASS}*$`,
NONBLANK = `${BLANK_CLASS}+$`;
const options = context.options[0] || {},
skipBlankLines = options.skipBlankLines || false,
ignoreComments = options.ignoreComments || false;
/**
* Report the error message
* @param {ASTNode} node node to report
* @param {int[]} location range information
* @param {int[]} fixRange Range based on the whole program
* @returns {void}
*/
function report(node, location, fixRange) {
/*
* Passing node is a bit dirty, because message data will contain big
* text in `source`. But... who cares :) ?
* One more kludge will not make worse the bloody wizardry of this
* plugin.
*/
context.report({
node,
loc: location,
messageId: "trailingSpace",
fix(fixer) {
return fixer.removeRange(fixRange);
}
});
}
/**
* Given a list of comment nodes, return the line numbers for those comments.
* @param {Array} comments An array of comment nodes.
* @returns {number[]} An array of line numbers containing comments.
*/
function getCommentLineNumbers(comments) {
const lines = new Set();
comments.forEach(comment => {
const endLine = comment.type === "Block"
? comment.loc.end.line - 1
: comment.loc.end.line;
for (let i = comment.loc.start.line; i <= endLine; i++) {
lines.add(i);
}
});
return lines;
}
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
Program: function checkTrailingSpaces(node) {
/*
* Let's hack. Since Espree does not return whitespace nodes,
* fetch the source code and do matching via regexps.
*/
const re = new RegExp(NONBLANK, "u"),
skipMatch = new RegExp(SKIP_BLANK, "u"),
lines = sourceCode.lines,
linebreaks = sourceCode.getText().match(astUtils.createGlobalLinebreakMatcher()),
comments = sourceCode.getAllComments(),
commentLineNumbers = getCommentLineNumbers(comments);
let totalLength = 0,
fixRange = [];
for (let i = 0, ii = lines.length; i < ii; i++) {
const lineNumber = i + 1;
/*
* Always add linebreak length to line length to accommodate for line break (\n or \r\n)
* Because during the fix time they also reserve one spot in the array.
* Usually linebreak length is 2 for \r\n (CRLF) and 1 for \n (LF)
*/
const linebreakLength = linebreaks && linebreaks[i] ? linebreaks[i].length : 1;
const lineLength = lines[i].length + linebreakLength;
const matches = re.exec(lines[i]);
if (matches) {
const location = {
start: {
line: lineNumber,
column: matches.index
},
end: {
line: lineNumber,
column: lineLength - linebreakLength
}
};
const rangeStart = totalLength + location.start.column;
const rangeEnd = totalLength + location.end.column;
const containingNode = sourceCode.getNodeByRangeIndex(rangeStart);
if (containingNode && containingNode.type === "TemplateElement" &&
rangeStart > containingNode.parent.range[0] &&
rangeEnd < containingNode.parent.range[1]) {
totalLength += lineLength;
continue;
}
/*
* If the line has only whitespace, and skipBlankLines
* is true, don't report it
*/
if (skipBlankLines && skipMatch.test(lines[i])) {
totalLength += lineLength;
continue;
}
fixRange = [rangeStart, rangeEnd];
if (!ignoreComments || !commentLineNumbers.has(lineNumber)) {
report(node, location, fixRange);
}
}
totalLength += lineLength;
}
}
};
}
};