Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### Código de Conduta para Colaboradores
# Código de Conduta para Colaboradores

## Nossa promessa

Expand Down
82 changes: 64 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Basic Configuration:
--path This option allows you to specify the path to the file(s) to be analyzed.
--config This option allows you to specify an additional configuration file for Moenda.
--exclude This option allows you to specify which file extensions Moenda must ignore.(optional)
--context This option allows you to generate a context for markdown files. (optional)
```

#### Rules
Expand All @@ -34,10 +35,10 @@ Use a JavaScript file to specify configuration information for your files. This

```js
const config = {
lineCounter: {limit:60},
LineAboveXCharacters: {limit:30},
firstSectionStartsWithHx: {limit: 3},
consecutiveBlankLines: {limit: 1}
ruleLineCounter: {limit:60},
ruleLineAboveXCharacters: {limit:30},
ruleFirstSectionStartsWithHx: {limit: 3},
ruleConsecutiveBlankLines: {limit: 1}
}

module.exports = config;
Expand All @@ -48,35 +49,80 @@ After run the command you'll see the report in your terminal.
$ moenda.js --rules /home/user/md-rules.js --path /home/user/sut --exclude html,java --config configOne.js

/home/user/sut/file.js
12:76 error "This line must not exceed 75 characters." LineAboveXCharacters()
51:- error "This file is expected to have a maximum of 50 lines" lineCounter()
62:- error "This file is expected to have a maximum of 1 consecutive blank lines" consecutiveBlankLines()
12:76 error "This line must not exceed 75 characters." ruleLineAboveXCharacters()
51:- error "This file is expected to have a maximum of 50 lines" ruleLineCounter()
62:- error "This file is expected to have a maximum of 1 consecutive blank lines" ruleConsecutiveBlankLines()

* 4 problem(s) (2 errors)
* 0 info(s)


/home/user/sut/markdown.md
1:4 error The first section of the file does not start with H1 firstSectionStartsWithHx()
1:4 error The file does not have increasing and decreasing sections NeighboringSections()
15:76 error "This line must not exceed 75 characters." LineAboveXCharacters()
51:- error "This file is expected to have a maximum of 50 lines" lineCounter()
1:4 error The first section of the file does not start with H1 ruleFirstSectionStartsWithHx()
1:4 error The file does not have increasing and decreasing sections ruleNeighboringSections()
15:76 error "This line must not exceed 75 characters." ruleLineAboveXCharacters()
51:- error "This file is expected to have a maximum of 50 lines" ruleLineCounter()

* 4 problem(s) (4 errors)
* 0 info(s)

$ moenda --rules /home/felipe/fork/Moenda/src/rules/MD/MDRules.js --path /home/felipe/fork/Moenda/README.md --config /home/felipe/fork/Moenda/src/config.js --context true


/home/felipe/fork/Moenda/README.md
-:- info The file has 94 line(s) ruleLineCounter()
1:1 error The first section of the file does not start with H3 ruleFirstSectionStartsWithHx()
5:31 error This line must not exceed 30 characters. ruleLineAboveXCharacters()
30:- error This file is expected to have a maximum of 1 consecutive blank lines ruleConsecutiveBlankLines()
45:4 error The file does not have increasing and decreasing sections ruleNeighboringSections()
94:- error This file is expected to have a minimum of 600 lines ruleLessThanXLines()

* 5 problem(s) (5 errors)
* 1 info(s)
{
[
{ type: 'inLineCode', value: '`--path || ', line: 25, quantity: 1 },
{
type: 'link',
value: 'https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L260',
line: 85,
quantity: 1
},
{
type: 'text',
value: ' - Analyzes whether the file has more consecutive blank lines than allowed.',
line: 86,
quantity: 1
},
{ type: 'section', value: 2, line: 91, quantity: 1 },
{ type: 'text', value: 'MIT © Moenda', line: 93, quantity: 1 }
],
sections: 1,
links: 1,
lists: 0,
images: 0,
inLineCode: 1,
texts: 2
}

```

## Built-in Rules:

1. [lineCounter](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L6)
2. [LessThanXLines](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L37)
3. [LineAboveXCharacters](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L68)
4. [firstSectionStartsWithHx](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L103)
5. [NeighboringSections](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L159)
6. [inconsistencyOfSpaces](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L209)
7. [consecutiveBlankLines](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L260)
1. [ruleLineCounter](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L6)
- Counts the file lines.
2. [ruleLessThanXLines](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L37)
- Evaluates whether a file has fewer lines than necessary.
3. [ruleLineAboveXCharacters](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L68)
- Evaluates whether a line has more characters than allowed.
4. [ruleFirstSectionStartsWithHx](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L103)
- Analyzes whether the first section of the file is of the determined order.
5. [ruleNeighboringSections](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L159)
- Analyzes whether sections have inconsistencies.
6. [ruleInconsistencyOfSpaces](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L209)
- It finds spaces inconsistency.
7. [ruleConsecutiveBlankLines](https://github.com/SPLAB-UFCG/Moenda/blob/master/src/index.js#L260)
- Analyzes whether the file has more consecutive blank lines than allowed.



Expand Down
33 changes: 25 additions & 8 deletions bin/moenda.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
#!/usr/bin/env node

const util = require('../src/util');
const os = require('os');
const {Command} = require('commander');
const program = new Command();
const genericRules = require("../src/rules/genericRules/genericRules");
const mdContext = require("../src/context/MDContext/MDContext");

program.version('0.0.1');

//Building the CLI
program
.option('-r, --rules <type>', 'Rules file')
.option('-p, --path <type>', 'Archive for analysis')
.option('-e, --exclude <type>', 'Exclude Extensions')
.option('-c, --config <type>', 'Configurations');
.option('-c, --config <type>', 'Configurations')
.option('-t, --context <type>', 'Contexts')

program.parse(process.argv);

/**
* Analyzes whether the informed path corresponds to a file or a directory, then calls the function that constructs the output.
*/
function main() {
if (util.testIfIsFile(program.path).status === true) {
util.exitAid(program);
if (util.testIfIsFile(program.path)) {
console.log(util.exitAid(program, genericRules));

if (program.context === "true"){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? it sounds more correct a boolean

console.log(mdContext.contextGenerator(program.path));
}
} else {
let parameter = '';

if (program.exclude) {
parameter += program.exclude;
}

const array = util.directoryFiles(program.path, parameter).data;

/**
* Creates an array with the files in the directory informed by program.path, ignoring the extensions informed in program.exclude.
*/
const array = util.directoryFiles(program.path, parameter);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not?
const array = util.directoryFiles(program.path, program.exclude);


for (let i = 0; i < array.length; i++) {
util.exitAid(program, array[i]);
console.log(util.exitAid(program, genericRules, array[i]));
if (program.context === "true"){
if (mdContext.contextGenerator(array[i]) !== null)
console.log(mdContext.contextGenerator(array[i]));
}
}
}
}
Expand Down
Loading