Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hairballs

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hairballs - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

src/templates/partials/occurrences.hbs

0

CHANGELOG.md

@@ -0,0 +0,0 @@ # 0.1.1 - April 7, 2015

4

package.json
{
"name": "hairballs",
"version": "0.1.1",
"version": "0.2.0",
"description": "Shared utilities for Lint Reporters",

@@ -31,3 +31,3 @@ "keywords": [

"dependencies": {
"handlebars": "4.0.5"
"handlebars": "4.0.13"
},

@@ -34,0 +34,0 @@ "devDependencies": {

@@ -0,0 +0,0 @@ # Shared Libraries for Lint Reporters

@@ -21,4 +21,4 @@ 'use strict';

exports.errorOccurances = [];
exports.warningOccurances = [];
exports.errorOccurrences = [];
exports.warningOccurrences = [];

@@ -91,8 +91,8 @@ /**

/**
* Helper for sorting occurances
* Helper for sorting occurrences
* @param {object} a - First object to compare
* @param {object} b - Second object to compare
* @returns {int} - Value used to sort the occurances
* @returns {int} - Value used to sort the occurrences
*/
exports.sortOccurances = function(a, b) {
exports.sortOccurrences = function(a, b) {
return b.count - a.count;

@@ -103,24 +103,24 @@ };

/**
* Count the occurances of an alert
* Count the occurrences of an alert
* @param {string} key - Linting rule
* @param {array} severity - Array of occurances
* @param {array} severity - Array of occurrences
* @param {string|boolean} ruleUrl - URL of rule for reference
* @returns {void}
*/
exports.updateOccurance = function(key, severity, ruleUrl) {
var foundOccurance = false;
exports.updateOccurrence = function(key, severity, ruleUrl) {
var foundOccurrence = false;
var occurances = (severity === 'error' || severity === 2)
? this.errorOccurances : this.warningOccurances;
var occurrences = (severity === 'error' || severity === 2)
? this.errorOccurrences : this.warningOccurrences;
for (var x = 0; x < occurances.length; x++) {
if (occurances[x].name === key) {
foundOccurance = true;
occurances[x].count++;
for (var x = 0; x < occurrences.length; x++) {
if (occurrences[x].name === key) {
foundOccurrence = true;
occurrences[x].count++;
}
}
if (!foundOccurance) {
occurances.push({ name: key, count: 1, ruleUrl: ruleUrl});
if (!foundOccurrence) {
occurrences.push({ name: key, count: 1, ruleUrl: ruleUrl});
}
};

@@ -0,0 +0,0 @@ /**

@@ -86,4 +86,4 @@ /**

// occurances
var occurances = fs.readFileSync(path.join(partialsPath, 'occurances.hbs'),
// occurrences
var occurrences = fs.readFileSync(path.join(partialsPath, 'occurrences.hbs'),
{ encoding: 'utf-8' }

@@ -105,3 +105,3 @@ );

fileBreakdown: handlebars.compile(fileBreakdown),
occurances: handlebars.compile(occurances),
occurrences: handlebars.compile(occurrences),
js: handlebars.compile(js),

@@ -108,0 +108,0 @@ css: handlebars.compile(css)

@@ -92,3 +92,3 @@ 'use strict';

describe('sortOccurances(a, b)', function() {
describe('sortOccurrences(a, b)', function() {
it('should sort', function() {

@@ -98,3 +98,3 @@ var a1 = { count: 4 };

expect(index.sortOccurances(a1, b1)).to.equal(-1);
expect(index.sortOccurrences(a1, b1)).to.equal(-1);

@@ -104,3 +104,3 @@ var a2 = { count: 5 };

expect(index.sortOccurances(a2, b2)).to.equal(1);
expect(index.sortOccurrences(a2, b2)).to.equal(1);

@@ -110,32 +110,32 @@ var a3 = { count: 2 };

expect(index.sortOccurances(a3, b3)).to.equal(0);
expect(index.sortOccurrences(a3, b3)).to.equal(0);
});
});
describe('updateOccurance(key, severity, ruleUrl)', function() {
it('should update error occurances', function() {
index.updateOccurance('errorKey', 'error', 'url.html');
describe('updateOccurrence(key, severity, ruleUrl)', function() {
it('should update error occurrences', function() {
index.updateOccurrence('errorKey', 'error', 'url.html');
expect(index.errorOccurances[0].name).to.equal('errorKey');
expect(index.errorOccurances[0].count).to.equal(1);
expect(index.errorOccurances[0].ruleUrl).to.equal('url.html');
expect(index.errorOccurrences[0].name).to.equal('errorKey');
expect(index.errorOccurrences[0].count).to.equal(1);
expect(index.errorOccurrences[0].ruleUrl).to.equal('url.html');
index.updateOccurance('errorKey', 2, 'url.html');
index.updateOccurance('errorKey', 'error', 'url.html');
index.updateOccurrence('errorKey', 2, 'url.html');
index.updateOccurrence('errorKey', 'error', 'url.html');
expect(index.errorOccurances[0].count).to.equal(3);
expect(index.errorOccurrences[0].count).to.equal(3);
});
it('should update warning occurances', function() {
index.updateOccurance('warningKey', 'warning', 'url.html');
it('should update warning occurrences', function() {
index.updateOccurrence('warningKey', 'warning', 'url.html');
expect(index.warningOccurances[0].name).to.equal('warningKey');
expect(index.warningOccurances[0].count).to.equal(1);
expect(index.warningOccurances[0].ruleUrl).to.equal('url.html');
expect(index.warningOccurrences[0].name).to.equal('warningKey');
expect(index.warningOccurrences[0].count).to.equal(1);
expect(index.warningOccurrences[0].ruleUrl).to.equal('url.html');
index.updateOccurance('warningKey', 1, 'url.html');
index.updateOccurance('warningKeyOther', 1, 'url.html');
index.updateOccurrence('warningKey', 1, 'url.html');
index.updateOccurrence('warningKeyOther', 1, 'url.html');
expect(index.warningOccurances[0].count).to.equal(2);
expect(index.warningOccurances[1].count).to.equal(1);
expect(index.warningOccurrences[0].count).to.equal(2);
expect(index.warningOccurrences[1].count).to.equal(1);
});

@@ -142,0 +142,0 @@ });

@@ -0,0 +0,0 @@ 'use strict';

@@ -28,4 +28,4 @@ 'use strict';

summary: summary,
warningOccurances: [],
errorOccurances: [],
warningOccurrences: [],
errorOccurrences: [],
files: [],

@@ -32,0 +32,0 @@ fullReport: false,

@@ -0,0 +0,0 @@ 'use strict';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc