Skip to content

Commit

Permalink
refactor: renomeia detektManager para linterManager
Browse files Browse the repository at this point in the history
  • Loading branch information
LeandroLM committed Jul 20, 2023
1 parent 1170dd6 commit 078ae8c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 73 deletions.
141 changes: 71 additions & 70 deletions dist/index.js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9558,7 +9558,76 @@ exports["default"] = _default;

/***/ }),

/***/ 3078:
/***/ 1267:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {


const fs = __nccwpck_require__(7147)
const path = __nccwpck_require__(1017)
const core = __nccwpck_require__(4181)
const { globSync } = __nccwpck_require__(5261)

/**
* Retorna todos os arquivos xml's
* @param {string} dirPath Caminho dos arquivos xml
* @example searchFilesXml()
* @output {files: [ 'exemplo.xml' ], path: dirPath}
*
*/
function searchFilesXml(dirPath) {
try {
core.info(`\u001b[38;5;6m[info] 🔍 Buscando arquivos xml -> ${dirPath}`)

let files = fs.readdirSync(dirPath)
files = files.filter((file) => path.extname(file) === '.xml')
core.info(`\u001b[38;5;6m[info] 📑 Arquivos encontrados para análise-> ${files.length}`)

return {files, path: dirPath}
} catch (error) {
core.info('\u001b[38;5;6m[info] 📑 Arquivos encontrados -> 0')
return {files: [], path: dirPath}
}
}

/**
* Retorna todos os arquivos com extensão .json presente em um diretório.
* A busca é feita de forma recursiva, em todos us subdiretórios do diretório informado.
*
* @param {string} dirpath Diretório onde os arquivos serão buscados.
* @returns {string[]} Um array com o caminho de todos os arquivos JSON encontrados.
*/
function searchJSONfiles(dirPath) {
const pattern = path.join(dirPath, '**/*.json')
return globSync(pattern)
}

/**
* Retorna a string gerada pela leitura do arquivo xml.
* @param {string} pathFile
* @example loadFile("file.xml")
* @output
*/
function loadFile(pathFile) {
let xml_string
try {
xml_string = fs.readFileSync(pathFile, 'utf8')
return xml_string
} catch (error) {
throw new Error('Erro ao ler arquivo.')
}

}

module.exports = {
loadFile,
searchFilesXml,
searchJSONfiles
}


/***/ }),

/***/ 4269:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const { searchFilesXml, loadFile, searchJSONfiles } = __nccwpck_require__(1267)
Expand Down Expand Up @@ -9649,74 +9718,6 @@ module.exports = {
buildCheckstyleObject
}

/***/ }),

/***/ 1267:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {


const fs = __nccwpck_require__(7147)
const path = __nccwpck_require__(1017)
const core = __nccwpck_require__(4181)
const { globSync } = __nccwpck_require__(5261)

/**
* Retorna todos os arquivos xml's
* @param {string} dirPath Caminho dos arquivos xml
* @example searchFilesXml()
* @output {files: [ 'exemplo.xml' ], path: dirPath}
*
*/
function searchFilesXml(dirPath) {
try {
core.info(`\u001b[38;5;6m[info] 🔍 Buscando arquivos xml -> ${dirPath}`)

let files = fs.readdirSync(dirPath)
files = files.filter((file) => path.extname(file) === '.xml')
core.info(`\u001b[38;5;6m[info] 📑 Arquivos encontrados para análise-> ${files.length}`)

return {files, path: dirPath}
} catch (error) {
core.info('\u001b[38;5;6m[info] 📑 Arquivos encontrados -> 0')
return {files: [], path: dirPath}
}
}

/**
* Retorna todos os arquivos com extensão .json presente em um diretório.
* A busca é feita de forma recursiva, em todos us subdiretórios do diretório informado.
*
* @param {string} dirpath Diretório onde os arquivos serão buscados.
* @returns {string[]} Um array com o caminho de todos os arquivos JSON encontrados.
*/
function searchJSONfiles(dirPath) {
const pattern = path.join(dirPath, '**/*.json')
return globSync(pattern)
}

/**
* Retorna a string gerada pela leitura do arquivo xml.
* @param {string} pathFile
* @example loadFile("file.xml")
* @output
*/
function loadFile(pathFile) {
let xml_string
try {
xml_string = fs.readFileSync(pathFile, 'utf8')
return xml_string
} catch (error) {
throw new Error('Erro ao ler arquivo.')
}

}

module.exports = {
loadFile,
searchFilesXml,
searchJSONfiles
}


/***/ }),

Expand Down Expand Up @@ -17658,7 +17659,7 @@ exports.LRUCache = LRUCache;
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
const { getDetektReport, getKtlintReport } = __nccwpck_require__(3078)
const { getDetektReport, getKtlintReport } = __nccwpck_require__(4269)
const { spawn } = __nccwpck_require__(2081)
const core = __nccwpck_require__(4181)

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getDetektReport, getKtlintReport } = require('./src/controller/detektManager')
const { getDetektReport, getKtlintReport } = require('./src/controller/linterManager')
const { spawn } = require('child_process')
const core = require('@actions/core')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ module.exports = {
getKtlintReport,
getCheckstylesFiles,
buildCheckstyleObject
}
}
2 changes: 1 addition & 1 deletion src/test/detektManager.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { buildCheckstyleObject, getCheckstylesFiles } = require('../controller/detektManager');
const { buildCheckstyleObject, getCheckstylesFiles } = require('../controller/linterManager');
const { loadFile, searchFilesXml } = require('../controller/fileManager');

jest.mock('../controller/fileManager');
Expand Down

0 comments on commit 078ae8c

Please sign in to comment.