From 68c43c6c0cb920ca9bfc5b5c9ddc50888f2ed13e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:30:14 +0000 Subject: [PATCH 01/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in ad6a95a according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/tests/integration_tests/test_ui.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tests/integration_tests/test_ui.py b/src/tests/integration_tests/test_ui.py index 9d7546cde..60627e4e2 100644 --- a/src/tests/integration_tests/test_ui.py +++ b/src/tests/integration_tests/test_ui.py @@ -2,13 +2,15 @@ import pytest from selenium import webdriver from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait + @pytest.fixture def browser(): return webdriver.Chrome() + def test_login(browser): # Test login functionality browser.get("https://pi-nexus-autonomous-banking-network.com/login") @@ -19,12 +21,14 @@ def test_login(browser): browser.find_element_by_name("login").click() WebDriverWait(browser, 10).until(EC.title_contains("Dashboard")) + def test_account_list(browser): # Test account list page browser.get("https://pi-nexus-autonomous-banking-network.com/accounts") account_list = browser.find_elements_by_css_selector(".account-list li") assert len(account_list) > 0 + def test_create_account(browser): # Test create account functionality browser.get("https://pi-nexus-autonomous-banking-network.com/accounts/new") From 89bf6983acf1db2f513c6753fa3ff42d82b314a0 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:33:58 +0000 Subject: [PATCH 02/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in fda8ed8 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/routes/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/routes/index.js b/src/routes/index.js index d1800ab91..cdb9ac6b2 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -1,8 +1,8 @@ -const express = require("express"); -const router = express.Router(); +const express = require('express') +const router = express.Router() -router.get("/", (req, res) => { - res.json({ message: "Welcome to the PI Nexus Autonomous Banking Network!" }); -}); +router.get('/', (req, res) => { + res.json({ message: 'Welcome to the PI Nexus Autonomous Banking Network!' }) +}) -module.exports = router; +module.exports = router From e7253c1dac864a34497f94cde16bf76eccd5dcac Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:34:57 +0000 Subject: [PATCH 03/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 89e8652 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/models/user.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/models/user.js b/src/models/user.js index e827eec76..2e171d0da 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -1,20 +1,20 @@ -const mongoose = require("mongoose"); -const bcrypt = require("bcrypt"); +const mongoose = require('mongoose') +const bcrypt = require('bcrypt') const UserSchema = new mongoose.Schema({ username: { type: String, required: true, unique: true }, - password: { type: String, required: true }, -}); + password: { type: String, required: true } +}) -UserSchema.pre("save", async function (next) { - if (this.isModified("password")) { - this.password = await bcrypt.hash(this.password, 10); +UserSchema.pre('save', async function (next) { + if (this.isModified('password')) { + this.password = await bcrypt.hash(this.password, 10) } - next(); -}); + next() +}) UserSchema.methods.comparePassword = function (password) { - return bcrypt.compare(password, this.password); -}; + return bcrypt.compare(password, this.password) +} -module.exports = mongoose.model("User", UserSchema); +module.exports = mongoose.model('User', UserSchema) From ffd3862b912eb5a9c04ee9c890001b094a11413e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:35:43 +0000 Subject: [PATCH 04/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 89490a3 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/controllers/accounts.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/controllers/accounts.js b/src/controllers/accounts.js index 7a59dbdaf..8b93c643f 100644 --- a/src/controllers/accounts.js +++ b/src/controllers/accounts.js @@ -1,16 +1,16 @@ -const Account = require("../models/account"); +const Account = require('../models/account') exports.list = async (req, res) => { - const accounts = await Account.find({ owner: req.user._id }); - res.json(accounts); -}; + const accounts = await Account.find({ owner: req.user._id }) + res.json(accounts) +} exports.create = async (req, res) => { const account = new Account({ account_name: req.body.account_name, initial_balance: req.body.initial_balance, - owner: req.user._id, - }); - await account.save(); - res.json({ message: "Account created!", account }); -}; + owner: req.user._id + }) + await account.save() + res.json({ message: 'Account created!', account }) +} From 42bfd84fe4d375635f12d40ba1cff54c8dd527a0 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:36:46 +0000 Subject: [PATCH 05/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 2c80799 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/controllers/transfers.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/controllers/transfers.js b/src/controllers/transfers.js index ecc8b9e1f..b20c4b778 100644 --- a/src/controllers/transfers.js +++ b/src/controllers/transfers.js @@ -1,31 +1,31 @@ -const Transfer = require("../models/transfer"); -const Account = require("../models/account"); +const Transfer = require('../models/transfer') +const Account = require('../models/account') exports.create = async (req, res) => { - const senderAccount = await Account.findById(req.body.sender_account_id); - const receiverAccount = await Account.findById(req.body.receiver_account_id); + const senderAccount = await Account.findById(req.body.sender_account_id) + const receiverAccount = await Account.findById(req.body.receiver_account_id) if (!senderAccount || !receiverAccount) { - return res.status(400).json({ message: "Account not found" }); + return res.status(400).json({ message: 'Account not found' }) } if (senderAccount.balance < req.body.amount) { - return res.status(400).json({ message: "Insufficient balance" }); + return res.status(400).json({ message: 'Insufficient balance' }) } const transfer = new Transfer({ sender_account_id: req.body.sender_account_id, receiver_account_id: req.body.receiver_account_id, - amount: req.body.amount, - }); + amount: req.body.amount + }) - await transfer.save(); + await transfer.save() - senderAccount.balance -= req.body.amount; - receiverAccount.balance += req.body.amount; + senderAccount.balance -= req.body.amount + receiverAccount.balance += req.body.amount - await senderAccount.save(); - await receiverAccount.save(); + await senderAccount.save() + await receiverAccount.save() - res.json({ message: "Transfer successful", transfer }); -}; + res.json({ message: 'Transfer successful', transfer }) +} From 80b0ed96b169f472a8d8a9f9d45e6920e92c47d5 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:39:06 +0000 Subject: [PATCH 06/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 0f8e78e according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/controllers/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/controllers/index.js b/src/controllers/index.js index 639a0fa07..6a19656de 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -1,10 +1,10 @@ -const express = require("express"); -const router = express.Router(); +const express = require('express') +const router = express.Router() -const AccountsController = require("./accounts"); -const TransfersController = require("./transfers"); +const AccountsController = require('./accounts') +const TransfersController = require('./transfers') -router.use("/accounts", AccountsController); -router.use("/transfers", TransfersController); +router.use('/accounts', AccountsController) +router.use('/transfers', TransfersController) -module.exports = router; +module.exports = router From a24ae6c88fad1cff68e196c712087dc036b429e8 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:40:03 +0000 Subject: [PATCH 07/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 6689b93 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/middleware/auth.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/middleware/auth.js b/src/middleware/auth.js index 46ae82670..3c436ec5a 100644 --- a/src/middleware/auth.js +++ b/src/middleware/auth.js @@ -1,20 +1,20 @@ -const jwt = require("jsonwebtoken"); -const User = require("../models/user"); +const jwt = require('jsonwebtoken') +const User = require('../models/user') const authenticate = async (req, res, next) => { - const token = req.header("Authorization")?.split(" ")[1]; + const token = req.header('Authorization')?.split(' ')[1] if (!token) { - return res.status(401).json({ message: "Access Denied" }); + return res.status(401).json({ message: 'Access Denied' }) } try { - const decoded = jwt.verify(token, process.env.JWT_SECRET); - req.user = await User.findById(decoded.user_id); - next(); + const decoded = jwt.verify(token, process.env.JWT_SECRET) + req.user = await User.findById(decoded.user_id) + next() } catch (error) { - res.status(400).json({ message: "Invalid Token" }); + res.status(400).json({ message: 'Invalid Token' }) } -}; +} -module.exports = authenticate; +module.exports = authenticate From d5de6876c59ca1eb7b58b298745fd94392450c71 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:41:06 +0000 Subject: [PATCH 08/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in eb12002 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/middleware/network.js | 42 ++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/middleware/network.js b/src/middleware/network.js index 8e58f6c1b..636f053e5 100644 --- a/src/middleware/network.js +++ b/src/middleware/network.js @@ -1,30 +1,40 @@ -const { PRIVATE_KEY, PRIVATE_KEY_PASSWORD, PRIVATE_KEY_PASSWORD_SALT, ENDPOINT, CHAIN_ID } = process.env; +const { + PRIVATE_KEY, + PRIVATE_KEY_PASSWORD, + PRIVATE_KEY_PASSWORD_SALT, + ENDPOINT, + CHAIN_ID +} = process.env -const Web3 = require("web3"); -const EthereumTx = require("ethereumjs-tx"); +const Web3 = require('web3') +const EthereumTx = require('ethereumjs-tx') -const web3 = new Web3(new Web3.providers.HttpProvider(ENDPOINT)); +const web3 = new Web3(new Web3.providers.HttpProvider(ENDPOINT)) const createTransaction = async (from, to, value) => { - const nonce = await web3.eth.getTransactionCount(from); - const gasPrice = await web3.eth.getGasPrice(); - const gasLimit = 21000; + const nonce = await web3.eth.getTransactionCount(from) + const gasPrice = await web3.eth.getGasPrice() + const gasLimit = 21000 const tx = new EthereumTx({ nonce, gasPrice, gasLimit, to, - value, - }); + value + }) - const privateKey = web3.utils.sha3(PRIVATE_KEY_PASSWORD + PRIVATE_KEY_PASSWORD_SALT); - tx.sign(privateKey); + const privateKey = web3.utils.sha3( + PRIVATE_KEY_PASSWORD + PRIVATE_KEY_PASSWORD_SALT + ) + tx.sign(privateKey) - const serializedTx = tx.serialize(); - const transactionHash = await web3.eth.sendSignedTransaction("0x" + serializedTx.toString("hex")); + const serializedTx = tx.serialize() + const transactionHash = await web3.eth.sendSignedTransaction( + '0x' + serializedTx.toString('hex') + ) - return transactionHash; -}; + return transactionHash +} -module.exports = createTransaction; +module.exports = createTransaction From 55734341a1313c63084a5eadf1b78eff52c6ccfc Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:42:03 +0000 Subject: [PATCH 09/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 564f06c according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/routes/transfers.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/routes/transfers.js b/src/routes/transfers.js index 01b221fe7..a61bd45bc 100644 --- a/src/routes/transfers.js +++ b/src/routes/transfers.js @@ -1,20 +1,24 @@ -const express = require("express"); -const router = express.Router(); +const express = require('express') +const router = express.Router() -const TransferController = require("../controllers/transfers"); -const authenticate = require("../middleware/auth"); -const createTransaction = require("../middleware/network"); +const TransferController = require('../controllers/transfers') +const authenticate = require('../middleware/auth') +const createTransaction = require('../middleware/network') -router.post("/", authenticate, async (req, res) => { +router.post('/', authenticate, async (req, res) => { try { - const transfer = await TransferController.create(req, res); - const transactionHash = await createTransaction(req.user.wallet_address, req.body.receiver_account_id, req.body.amount); - transfer.transaction_hash = transactionHash; - await transfer.save(); - res.json({ message: "Transfer successful", transfer }); + const transfer = await TransferController.create(req, res) + const transactionHash = await createTransaction( + req.user.wallet_address, + req.body.receiver_account_id, + req.body.amount + ) + transfer.transaction_hash = transactionHash + await transfer.save() + res.json({ message: 'Transfer successful', transfer }) } catch (error) { - res.status(400).json({ message: error.message }); + res.status(400).json({ message: error.message }) } -}); +}) -module.exports = router; +module.exports = router From b5bdfa51bc9c94e5a9e9153437e8be7ffc6f2fb7 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:45:17 +0000 Subject: [PATCH 10/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in b6c1ce5 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/app.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app.js b/src/app.js index a2ed7cd55..286ba6401 100644 --- a/src/app.js +++ b/src/app.js @@ -1,35 +1,35 @@ -const express = require("express"); -const bodyParser = require("body-parser"); -const cors = require("cors"); -const mongoose = require("mongoose"); +const express = require('express') +const bodyParser = require('body-parser') +const cors = require('cors') +const mongoose = require('mongoose') -const { JWT_SECRET, MONGODB_URI } = process.env; +const { JWT_SECRET, MONGODB_URI } = process.env -const app = express(); +const app = express() -app.use(bodyParser.json()); -app.use(cors()); +app.use(bodyParser.json()) +app.use(cors()) -const router = require("./routes"); -app.use("/api", router); +const router = require('./routes') +app.use('/api', router) const connectToMongoDB = async () => { try { await mongoose.connect(MONGODB_URI, { useNewUrlParser: true, useUnifiedTopology: true, - useCreateIndex: true, - }); - console.log("Connected to MongoDB"); + useCreateIndex: true + }) + console.log('Connected to MongoDB') } catch (error) { - console.error("Failed to connect to MongoDB", error); - process.exit(1); + console.error('Failed to connect to MongoDB', error) + process.exit(1) } -}; +} -connectToMongoDB(); +connectToMongoDB() -const PORT = process.env.PORT || 5000; +const PORT = process.env.PORT || 5000 app.listen(PORT, () => { - console.log(`Server running on port ${PORT}`); -}); + console.log(`Server running on port ${PORT}`) +}) From da49bfabc41058a06e53632a57af115bbab540d1 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:47:47 +0000 Subject: [PATCH 11/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 6ec06f1 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- src/models/transfer.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/models/transfer.js b/src/models/transfer.js index d1cf4802b..ca77421f7 100644 --- a/src/models/transfer.js +++ b/src/models/transfer.js @@ -1,12 +1,16 @@ -const mongoose = require("mongoose"); +const mongoose = require('mongoose') const transferSchema = new mongoose.Schema({ - sender_id: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true }, + sender_id: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: true + }, receiver_account_id: { type: String, required: true }, amount: { type: Number, required: true }, - transaction_hash: { type: String }, -}); + transaction_hash: { type: String } +}) -const Transfer = mongoose.model("Transfer", transferSchema); +const Transfer = mongoose.model('Transfer', transferSchema) -module.exports = Transfer; +module.exports = Transfer From 485044ae1ccf7f086420ab8ae29aaf7660247cee Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:27:48 +0000 Subject: [PATCH 12/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 6c0eb5a according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- risk_management/risk_assessment.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/risk_management/risk_assessment.py b/risk_management/risk_assessment.py index 6bdb51647..22e91a390 100644 --- a/risk_management/risk_assessment.py +++ b/risk_management/risk_assessment.py @@ -3,14 +3,17 @@ from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split + class RiskAssessment: def __init__(self, data): self.data = data - self.X = self.data.drop('risk_level', axis=1) - self.y = self.data['risk_level'] + self.X = self.data.drop("risk_level", axis=1) + self.y = self.data["risk_level"] def train_model(self): - X_train, X_test, y_train, y_test = train_test_split(self.X, self.y, test_size=0.2, random_state=42) + X_train, X_test, y_train, y_test = train_test_split( + self.X, self.y, test_size=0.2, random_state=42 + ) self.model = RandomForestClassifier(n_estimators=100, random_state=42) self.model.fit(X_train, y_train) From 79927ba69a05f3fb87b26ebc12bf45ab59d2319b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:28:26 +0000 Subject: [PATCH 13/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 22c05ff according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- risk_management/risk_mitigation.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/risk_management/risk_mitigation.py b/risk_management/risk_mitigation.py index 77d3327ca..c7166831e 100644 --- a/risk_management/risk_mitigation.py +++ b/risk_management/risk_mitigation.py @@ -4,13 +4,13 @@ def __init__(self, risk_assessment_model): def mitigate_risk(self, transaction): risk_level = self.risk_assessment_model.predict_risk(transaction) - if risk_level == 'high': + if risk_level == "high": # Implement risk mitigation strategies here # For example, you could flag the transaction for review or decline it altogether - return 'Flagged for review' - elif risk_level == 'medium': + return "Flagged for review" + elif risk_level == "medium": # Implement risk mitigation strategies here # For example, you could require additional authentication or verification - return 'Additional authentication required' + return "Additional authentication required" else: - return 'Transaction approved' + return "Transaction approved" From 6b60c228b4877663e3358a9f10694061ba7d9c93 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:29:00 +0000 Subject: [PATCH 14/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in a50f1a4 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- risk_management/risk_monitoring.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/risk_management/risk_monitoring.py b/risk_management/risk_monitoring.py index 52eaa2db9..653c69773 100644 --- a/risk_management/risk_monitoring.py +++ b/risk_management/risk_monitoring.py @@ -1,5 +1,6 @@ import time + class RiskMonitoring: def __init__(self, risk_assessment_model, risk_mitigation_model): self.risk_assessment_model = risk_assessment_model @@ -8,12 +9,16 @@ def __init__(self, risk_assessment_model, risk_mitigation_model): def monitor_risks(self, transactions): for transaction in transactions: risk_level = self.risk_assessment_model.predict_risk(transaction) - if risk_level == 'high': - mitigation_result = self.risk_mitigation_model.mitigate_risk(transaction) - print(f'High-risk transaction detected: {mitigation_result}') - elif risk_level == 'medium': - mitigation_result = self.risk_mitigation_model.mitigate_risk(transaction) - print(f'Medium-risk transaction detected: {mitigation_result}') + if risk_level == "high": + mitigation_result = self.risk_mitigation_model.mitigate_risk( + transaction + ) + print(f"High-risk transaction detected: {mitigation_result}") + elif risk_level == "medium": + mitigation_result = self.risk_mitigation_model.mitigate_risk( + transaction + ) + print(f"Medium-risk transaction detected: {mitigation_result}") else: - print(f'Low-risk transaction detected: Transaction approved') + print(f"Low-risk transaction detected: Transaction approved") time.sleep(1) From 2f9145a4eb9da80e3ea26a6ffa4e605c7c375a4f Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:30:55 +0000 Subject: [PATCH 15/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 5e79cd2 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- fraud_detection/fraud_detection_model.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fraud_detection/fraud_detection_model.py b/fraud_detection/fraud_detection_model.py index 7182d5030..edac1a2fa 100644 --- a/fraud_detection/fraud_detection_model.py +++ b/fraud_detection/fraud_detection_model.py @@ -3,14 +3,17 @@ from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split + class FraudDetectionModel: def __init__(self, data): self.data = data - self.X = self.data.drop('fraudulent', axis=1) - self.y = self.data['fraudulent'] + self.X = self.data.drop("fraudulent", axis=1) + self.y = self.data["fraudulent"] def train_model(self): - X_train, X_test, y_train, y_test = train_test_split(self.X, self.y, test_size=0.2, random_state=42) + X_train, X_test, y_train, y_test = train_test_split( + self.X, self.y, test_size=0.2, random_state=42 + ) self.model = RandomForestClassifier(n_estimators=100, random_state=42) self.model.fit(X_train, y_train) From c33a43b380a578fa86cd2a7ecc932d25990ec5e2 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:31:32 +0000 Subject: [PATCH 16/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 0f53969 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- fraud_detection/anomaly_detection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fraud_detection/anomaly_detection.py b/fraud_detection/anomaly_detection.py index 290777c23..1295cd588 100644 --- a/fraud_detection/anomaly_detection.py +++ b/fraud_detection/anomaly_detection.py @@ -2,6 +2,7 @@ import pandas as pd from sklearn.ensemble import IsolationForest + class AnomalyDetection: def __init__(self, transaction_data): self.transaction_data = transaction_data From e7c52aa573167b9b7b4bfd3aa2b02747a22b0578 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:32:12 +0000 Subject: [PATCH 17/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 9e452d3 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- fraud_detection/fraud_response.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fraud_detection/fraud_response.py b/fraud_detection/fraud_response.py index b4ee601cd..199695e3e 100644 --- a/fraud_detection/fraud_response.py +++ b/fraud_detection/fraud_response.py @@ -6,13 +6,13 @@ def __init__(self, fraud_detection_model, anomaly_detection): def respond_to_fraud(self, transactions): for transaction in transactions: fraud_level = self.fraud_detection_model.predict_fraud(transaction) - if fraud_level == 'fraudulent': + if fraud_level == "fraudulent": anomaly_score = self.anomaly_detection.detect_anomalies(transaction) if anomaly_score == -1: # Implement fraud response strategies here # For example, you could flag the transaction for review or decline it altogether - print('Fraudulent transaction detected: Flagged for review') + print("Fraudulent transaction detected: Flagged for review") else: - print('Anomalous transaction detected: Flagged for review') + print("Anomalous transaction detected: Flagged for review") else: - print('Non-fraudulent transaction detected: Transaction approved') + print("Non-fraudulent transaction detected: Transaction approved") From b7e68ab2de5af5e1c68508a1e68df88b2afd403c Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:34:37 +0000 Subject: [PATCH 18/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 76f80ff according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- customer_service/knowledge_base.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/customer_service/knowledge_base.py b/customer_service/knowledge_base.py index eab799fb7..267a37c3a 100644 --- a/customer_service/knowledge_base.py +++ b/customer_service/knowledge_base.py @@ -1,18 +1,18 @@ class KnowledgeBase: def __init__(self): self.knowledge_base = { - 'account': { - 'open': 'To open a new account, please visit our website and fill out the account opening form.', - 'close': 'To close an existing account, please contact our customer support team.', - 'balance': 'To check your account balance, please log in to your account on our website or mobile app.' + "account": { + "open": "To open a new account, please visit our website and fill out the account opening form.", + "close": "To close an existing account, please contact our customer support team.", + "balance": "To check your account balance, please log in to your account on our website or mobile app.", }, - 'transaction': { - 'make': 'To make a new transaction, please log in to your account on our website or mobile app.', - 'history': 'To view your transaction history, please log in to your account on our website or mobile app.' + "transaction": { + "make": "To make a new transaction, please log in to your account on our website or mobile app.", + "history": "To view your transaction history, please log in to your account on our website or mobile app.", + }, + "other": { + "help": "For assistance, please contact our customer support team." }, - 'other': { - 'help': 'For assistance, please contact our customer support team.' - } } def get_response(self, intent): @@ -21,4 +21,4 @@ def get_response(self, intent): if value: return self.knowledge_base[key] else: - return self.knowledge_base['other'] + return self.knowledge_base["other"] From 8bad75308164cbed814c02d5b825da00c0dcfe6d Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:35:08 +0000 Subject: [PATCH 19/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 2e40b65 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- customer_service/natural_language_processing.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/customer_service/natural_language_processing.py b/customer_service/natural_language_processing.py index 07490f49a..6a1aef356 100644 --- a/customer_service/natural_language_processing.py +++ b/customer_service/natural_language_processing.py @@ -1,6 +1,7 @@ import spacy -nlp = spacy.load('en_core_web_sm') +nlp = spacy.load("en_core_web_sm") + class NLP: def __init__(self): @@ -13,14 +14,14 @@ def extract_entities(self, text): def extract_intent(self, text): doc = self.nlp(text) - intents = {'account': False, 'transaction': False, 'other': False} + intents = {"account": False, "transaction": False, "other": False} for token in doc: - if token.text.lower() in ['account', 'accounts']: - intents['account'] = True - elif token.text.lower() in ['transaction', 'transactions']: - intents['transaction'] = True + if token.text.lower() in ["account", "accounts"]: + intents["account"] = True + elif token.text.lower() in ["transaction", "transactions"]: + intents["transaction"] = True if any(intents.values()): return intents else: - intents['other'] = True + intents["other"] = True return intents From 02498383dd22ece0ab4d8f1d9345504a4534891c Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:35:18 +0000 Subject: [PATCH 20/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 896f93f according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- customer_service/chatbot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/customer_service/chatbot.py b/customer_service/chatbot.py index 8ff98a9a1..786d199bd 100644 --- a/customer_service/chatbot.py +++ b/customer_service/chatbot.py @@ -1,5 +1,6 @@ import time + class Chatbot: def __init__(self, nlp_model, knowledge_base): self.nlp_model = nlp_model @@ -9,6 +10,6 @@ def chat(self, user_input): entities = self.nlp_model.extract_entities(user_input) intent = self.nlp_model.extract_intent(user_input) response = self.knowledge_base.get_response(intent) - print('User:', user_input) - print('Chatbot:', response) + print("User:", user_input) + print("Chatbot:", response) time.sleep(1) From 5e6d39e0812b60e65ceaa38144822b2ba85dd6a8 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:37:12 +0000 Subject: [PATCH 21/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 978d3bc according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- .../transaction_validation.py | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/transaction_processing/transaction_validation.py b/transaction_processing/transaction_validation.py index f119832ff..23da6ba7e 100644 --- a/transaction_processing/transaction_validation.py +++ b/transaction_processing/transaction_validation.py @@ -1,17 +1,18 @@ import re + class TransactionValidation: def __init__(self): self.validation_rules = { - 'account_number': { - 'regex': r'^\d{10}$', - 'message': 'Invalid account number format. Please enter a 10-digit account number.' + "account_number": { + "regex": r"^\d{10}$", + "message": "Invalid account number format. Please enter a 10-digit account number.", + }, + "amount": { + "min": 0, + "max": 1000000, + "message": "Transaction amount must be between 0 and 1,000,000.", }, - 'amount': { - 'min': 0, - 'max': 1000000, - 'message': 'Transaction amount must be between 0 and 1,000,000.' - } } def validate_transaction(self, transaction): @@ -19,13 +20,17 @@ def validate_transaction(self, transaction): for field, rules in self.validation_rules.items(): if field in transaction: for rule in rules: - if rule == 'regex': + if rule == "regex": if not re.match(rules[rule], transaction[field]): - errors.append(rules['message']) - elif rule == 'min': + errors.append(rules["message"]) + elif rule == "min": if float(transaction[field]) < rules[rule]: - errors.append(f'Transaction amount must be at least {rules[rule]}') - elif rule == 'max': + errors.append( + f"Transaction amount must be at least {rules[rule]}" + ) + elif rule == "max": if float(transaction[field]) > rules[rule]: - errors.append(f'Transaction amount must not exceed {rules[rule]}') + errors.append( + f"Transaction amount must not exceed {rules[rule]}" + ) return errors From 8660b46cdb209f4f63422bd9841bcc2a2799b342 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:37:51 +0000 Subject: [PATCH 22/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in fd4163d according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- transaction_processing/transaction_routing.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/transaction_processing/transaction_routing.py b/transaction_processing/transaction_routing.py index e11ee5ea2..499748e38 100644 --- a/transaction_processing/transaction_routing.py +++ b/transaction_processing/transaction_routing.py @@ -1,18 +1,20 @@ class TransactionRouter: def __init__(self): self.routing_rules = { - 'domestic': { - 'regex': r'^\d{10}$', - 'message': 'Invalid account number format. Please enter a 10-digit account number.' + "domestic": { + "regex": r"^\d{10}$", + "message": "Invalid account number format. Please enter a 10-digit account number.", + }, + "international": { + "regex": r"^\d{12}$", + "message": "Invalid account number format. Please enter a 12-digit account number.", }, - 'international': { - 'regex': r'^\d{12}$', - 'message': 'Invalid account number format. Please enter a 12-digit account number.' - } } def route_transaction(self, transaction): for rule in self.routing_rules: - if re.match(self.routing_rules[rule]['regex'], transaction['account_number']): + if re.match( + self.routing_rules[rule]["regex"], transaction["account_number"] + ): return rule - raise ValueError('Invalid account number format.') + raise ValueError("Invalid account number format.") From 057a7d44c835d28b79132f29c66146cbd26a5fa0 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:38:25 +0000 Subject: [PATCH 23/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in d504395 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- transaction_processing/transaction_processing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/transaction_processing/transaction_processing.py b/transaction_processing/transaction_processing.py index df41a2cb5..133311667 100644 --- a/transaction_processing/transaction_processing.py +++ b/transaction_processing/transaction_processing.py @@ -1,5 +1,6 @@ import time + class TransactionProcessor: def __init__(self, transaction_validator, transaction_router): self.transaction_validator = transaction_validator @@ -8,11 +9,11 @@ def __init__(self, transaction_validator, transaction_router): def process_transaction(self, transaction): errors = self.transaction_validator.validate_transaction(transaction) if errors: - print('Transaction errors:', errors) + print("Transaction errors:", errors) return False else: channel = self.transaction_router.route_transaction(transaction) - print('Transaction routed to:', channel) + print("Transaction routed to:", channel) time.sleep(1) - print('Transaction processed successfully.') + print("Transaction processed successfully.") return True From 6115a10ed0183c4389ddc77018b6ad8e01e98b4f Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:41:30 +0000 Subject: [PATCH 24/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 607fe54 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- data_analytics/data_ingestion.py | 1 + 1 file changed, 1 insertion(+) diff --git a/data_analytics/data_ingestion.py b/data_analytics/data_ingestion.py index 7cf151c16..5183e94cc 100644 --- a/data_analytics/data_ingestion.py +++ b/data_analytics/data_ingestion.py @@ -1,5 +1,6 @@ import pandas as pd + class DataIngestion: def __init__(self, data_source): self.data_source = data_source From 33febf4d5ae9cc85b290be6f7bcf959e009a6c9f Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:41:55 +0000 Subject: [PATCH 25/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 6972938 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- data_analytics/data_analysis.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/data_analytics/data_analysis.py b/data_analytics/data_analysis.py index 20bc30414..88523a5c6 100644 --- a/data_analytics/data_analysis.py +++ b/data_analytics/data_analysis.py @@ -2,6 +2,7 @@ import pandas as pd from sklearn.cluster import KMeans + class DataAnalysis: def __init__(self, data): self.data = data @@ -9,16 +10,18 @@ def __init__(self, data): def analyze_data(self): # Perform data cleaning and preprocessing self.data = self.data.dropna() - self.data = pd.get_dummies(self.data, columns=['transaction_type']) + self.data = pd.get_dummies(self.data, columns=["transaction_type"]) # Perform data analysis - kmeans = KMeans(n_clusters=3, random_state=0).fit(self.data[['amount', 'frequency']]) - self.data['cluster'] = kmeans.labels_ + kmeans = KMeans(n_clusters=3, random_state=0).fit( + self.data[["amount", "frequency"]] + ) + self.data["cluster"] = kmeans.labels_ # Perform statistical analysis summary_stats = self.data.describe() - summary_stats.loc['count'] = len(self.data) - summary_stats.loc['mean'] = np.mean(self.data) - summary_stats.loc['std'] = np.std(self.data) + summary_stats.loc["count"] = len(self.data) + summary_stats.loc["mean"] = np.mean(self.data) + summary_stats.loc["std"] = np.std(self.data) return summary_stats From b7008e947202f7868b732d111fb13d9d4cecfa33 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:42:10 +0000 Subject: [PATCH 26/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 7fb3d57 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- data_analytics/data_visualization.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data_analytics/data_visualization.py b/data_analytics/data_visualization.py index 96414dd96..3f711a046 100644 --- a/data_analytics/data_visualization.py +++ b/data_analytics/data_visualization.py @@ -1,16 +1,17 @@ import plotly.express as px + class DataVisualization: def __init__(self, data): self.data = data def visualize_data(self): # Create interactive dashboards - fig = px.scatter(self.data, x='amount', y='frequency', color='cluster') + fig = px.scatter(self.data, x="amount", y="frequency", color="cluster") fig.show() - fig = px.histogram(self.data, x='transaction_type', nbins=20) + fig = px.histogram(self.data, x="transaction_type", nbins=20) fig.show() - fig = px.box(self.data, x='cluster', y='amount') + fig = px.box(self.data, x="cluster", y="amount") fig.show() From 6da95e80204b689df0fa74169c55bd283bcba8eb Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:43:31 +0000 Subject: [PATCH 27/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 1c54c9a according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- security/authentication.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/security/authentication.py b/security/authentication.py index f85c9eb66..54d08b6c3 100644 --- a/security/authentication.py +++ b/security/authentication.py @@ -1,14 +1,19 @@ import hashlib import secrets + class Authentication: def __init__(self): self.salt = secrets.token_hex(16) def generate_password_hash(self, password): - password_hash = hashlib.pbkdf2_hmac('sha256', password.encode(), self.salt.encode(), 100000) + password_hash = hashlib.pbkdf2_hmac( + "sha256", password.encode(), self.salt.encode(), 100000 + ) return password_hash.hex() def verify_password(self, password, password_hash): - password_hash_check = hashlib.pbkdf2_hmac('sha256', password.encode(), self.salt.encode(), 100000) + password_hash_check = hashlib.pbkdf2_hmac( + "sha256", password.encode(), self.salt.encode(), 100000 + ) return password_hash_check.hex() == password_hash From 92ceca2a091895a1dff8f25edb7473f23bf22fcc Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:46:36 +0000 Subject: [PATCH 28/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 8c0dbcc according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- system_monitoring/system_monitoring.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/system_monitoring/system_monitoring.py b/system_monitoring/system_monitoring.py index 9db46a92e..2c874966e 100644 --- a/system_monitoring/system_monitoring.py +++ b/system_monitoring/system_monitoring.py @@ -1,18 +1,20 @@ -import psutil import time +import psutil + + class SystemMonitoring: def __init__(self): self.cpu_percent = psutil.cpu_percent() self.memory_percent = psutil.virtual_memory().percent - self.disk_percent = psutil.disk_usage('/').percent + self.disk_percent = psutil.disk_usage("/").percent def monitor_system(self): while True: time.sleep(60) self.cpu_percent = psutil.cpu_percent() self.memory_percent = psutil.virtual_memory().percent - self.disk_percent = psutil.disk_usage('/').percent - print(f'CPU: {self.cpu_percent}%') - print(f'Memory: {self.memory_percent}%') - print(f'Disk: {self.disk_percent}%') + self.disk_percent = psutil.disk_usage("/").percent + print(f"CPU: {self.cpu_percent}%") + print(f"Memory: {self.memory_percent}%") + print(f"Disk: {self.disk_percent}%") From 142eef2fd3590b2473140e012dbd798bb2c0e470 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:47:06 +0000 Subject: [PATCH 29/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in a442f07 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- system_monitoring/issue_detection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system_monitoring/issue_detection.py b/system_monitoring/issue_detection.py index 8e65205c6..ee70d6e36 100644 --- a/system_monitoring/issue_detection.py +++ b/system_monitoring/issue_detection.py @@ -4,8 +4,8 @@ def __init__(self, system_monitoring): def detect_issues(self): if self.system_monitoring.cpu_percent > 80: - print('High CPU usage detected!') + print("High CPU usage detected!") if self.system_monitoring.memory_percent > 80: - print('High memory usage detected!') + print("High memory usage detected!") if self.system_monitoring.disk_percent > 80: - print('High disk usage detected!') + print("High disk usage detected!") From 4c5947a79d200871e99b7e91cbaed4e0034600c6 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:48:03 +0000 Subject: [PATCH 30/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 01d2c0f according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- system_monitoring/self_healing.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system_monitoring/self_healing.py b/system_monitoring/self_healing.py index c0cc472de..f88eed8f4 100644 --- a/system_monitoring/self_healing.py +++ b/system_monitoring/self_healing.py @@ -1,10 +1,11 @@ import subprocess + class SelfHealing: def __init__(self): pass def heal_system(self): # Implement automatic healing techniques - subprocess.run(['systemctl', 'restart', 'nginx']) - subprocess.run(['systemctl', 'restart', 'postgresql']) + subprocess.run(["systemctl", "restart", "nginx"]) + subprocess.run(["systemctl", "restart", "postgresql"]) From 9964671466c3ce456a9901fa2fc96dfde85f94f9 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:55:25 +0000 Subject: [PATCH 31/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in d94390d according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- network/networking.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/network/networking.py b/network/networking.py index 0425688bf..177b46779 100644 --- a/network/networking.py +++ b/network/networking.py @@ -1,8 +1,9 @@ import socket + class Networking: def __init__(self): - self.host = '0.0.0.0' + self.host = "0.0.0.0" self.port = 8080 self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.bind((self.host, self.port)) @@ -11,7 +12,7 @@ def listen_for_connections(self): self.socket.listen(5) while True: connection, address = self.socket.accept() - print(f'Connection from {address} has been established!') + print(f"Connection from {address} has been established!") self.handle_connection(connection) def handle_connection(self, connection): From 1f0eaf436f5c55b8659efe5b3f53cc81b703398d Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:56:43 +0000 Subject: [PATCH 32/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 2f1562d according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- database/database.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/database/database.py b/database/database.py index e8b01f30d..297d7e2e7 100644 --- a/database/database.py +++ b/database/database.py @@ -1,20 +1,27 @@ import sqlite3 + class Database: def __init__(self): - self.connection = sqlite3.connect('banking.db') + self.connection = sqlite3.connect("banking.db") self.cursor = self.connection.cursor() def create_table(self): - self.cursor.execute('''CREATE TABLE IF NOT EXISTS accounts (id INTEGER PRIMARY KEY, name TEXT, balance REAL)''') + self.cursor.execute( + """CREATE TABLE IF NOT EXISTS accounts (id INTEGER PRIMARY KEY, name TEXT, balance REAL)""" + ) self.connection.commit() def insert_account(self, name, balance): - self.cursor.execute("INSERT INTO accounts (name, balance) VALUES (?, ?)", (name, balance)) + self.cursor.execute( + "INSERT INTO accounts (name, balance) VALUES (?, ?)", (name, balance) + ) self.connection.commit() def update_account(self, id, name, balance): - self.cursor.execute("UPDATE accounts SET name=?, balance=? WHERE id=?", (name, balance, id)) + self.cursor.execute( + "UPDATE accounts SET name=?, balance=? WHERE id=?", (name, balance, id) + ) self.connection.commit() def delete_account(self, id): From 9bfc887f15ccc9b283f984f37efde48c815805f4 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:58:00 +0000 Subject: [PATCH 33/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 6469eb1 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- machine_learning/machine_learning.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/machine_learning/machine_learning.py b/machine_learning/machine_learning.py index f53b8d14a..67f4caf10 100644 --- a/machine_learning/machine_learning.py +++ b/machine_learning/machine_learning.py @@ -1,19 +1,20 @@ -import pandas as pd import numpy as np +import pandas as pd from sklearn.linear_model import LinearRegression + class MachineLearning: def __init__(self): pass def train_model(self, data): - X = data[['feature1', 'feature2']] - y = data['target'] + X = data[["feature1", "feature2"]] + y = data["target"] model = LinearRegression() model.fit(X, y) return model def predict(self, model, data): - X = data[['feature1', 'feature2']] + X = data[["feature1", "feature2"]] y = model.predict(X) return y From b3e93d7a6884fe5ebdb1e1264411e413d2d2808b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:59:09 +0000 Subject: [PATCH 34/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in af2c73c according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- logging/logging.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/logging/logging.py b/logging/logging.py index 0db567ee3..dea11d2be 100644 --- a/logging/logging.py +++ b/logging/logging.py @@ -1,12 +1,13 @@ import logging + class Logging: def __init__(self): - self.logger = logging.getLogger('banking_network') + self.logger = logging.getLogger("banking_network") self.logger.setLevel(logging.DEBUG) def setup_logging(self): - formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') + formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") console_handler = logging.StreamHandler() console_handler.setLevel(logging.DEBUG) console_handler.setFormatter(formatter) From 48c09f7485dec7c98a15feb7cd79c5860c2f2a9f Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:00:27 +0000 Subject: [PATCH 35/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 383135d according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- testing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/testing.py b/testing.py index c6db305da..c507e3c5d 100644 --- a/testing.py +++ b/testing.py @@ -1,8 +1,10 @@ import unittest + class Testing(unittest.TestCase): def test_something(self): self.assertTrue(True) -if __name__ == '__main__': + +if __name__ == "__main__": unittest.main() From 35e090c304abfbc40223f44cc6d1e0d04e81780d Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:04:38 +0000 Subject: [PATCH 36/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 53d9e51 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- api/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/__init__.py b/api/__init__.py index f02c44442..e61ac4911 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -1,10 +1,12 @@ from flask import Flask -from .endpoints import endpoints + from .authentication import jwt_manager +from .endpoints import endpoints + def create_app(): app = Flask(__name__) - app.config.from_object('config') - app.register_blueprint(endpoints, url_prefix='/api') + app.config.from_object("config") + app.register_blueprint(endpoints, url_prefix="/api") jwt_manager.init_app(app) return app From 52b21f404999ced1f3bd22b8f31f8e9159e0b928 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:05:22 +0000 Subject: [PATCH 37/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 9746187 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- api/endpoints.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/api/endpoints.py b/api/endpoints.py index 8deff8235..6bc4572c6 100644 --- a/api/endpoints.py +++ b/api/endpoints.py @@ -1,24 +1,28 @@ -from flask import Blueprint, request, jsonify +from flask import Blueprint, jsonify, request + from .authentication import jwt_required -from .serializers import UserSchema, TransactionSchema +from .serializers import TransactionSchema, UserSchema + +endpoints = Blueprint("endpoints", __name__) -endpoints = Blueprint('endpoints', __name__) -@endpoints.route('/users', methods=['POST']) +@endpoints.route("/users", methods=["POST"]) def create_user(): user_schema = UserSchema() user = user_schema.load(request.get_json()) # Create user in the database return user_schema.jsonify(user), 201 -@endpoints.route('/users/', methods=['GET']) + +@endpoints.route("/users/", methods=["GET"]) @jwt_required() def get_user(user_id): user = get_user_from_database(user_id) user_schema = UserSchema() return user_schema.jsonify(user) -@endpoints.route('/users/', methods=['PUT']) + +@endpoints.route("/users/", methods=["PUT"]) @jwt_required() def update_user(user_id): user = get_user_from_database(user_id) @@ -27,14 +31,16 @@ def update_user(user_id): # Update user in the database return user_schema.jsonify(user) -@endpoints.route('/users/', methods=['DELETE']) + +@endpoints.route("/users/", methods=["DELETE"]) @jwt_required() def delete_user(user_id): user = get_user_from_database(user_id) # Delete user from the database - return '', 204 + return "", 204 -@endpoints.route('/transactions', methods=['POST']) + +@endpoints.route("/transactions", methods=["POST"]) @jwt_required() def create_transaction(): transaction_schema = TransactionSchema() @@ -42,21 +48,24 @@ def create_transaction(): # Create transaction in the database return transaction_schema.jsonify(transaction), 201 -@endpoints.route('/transactions', methods=['GET']) + +@endpoints.route("/transactions", methods=["GET"]) @jwt_required() def get_transactions(): transactions = get_transactions_from_database() transaction_schema = TransactionSchema(many=True) return transaction_schema.jsonify(transactions) -@endpoints.route('/transactions/', methods=['GET']) + +@endpoints.route("/transactions/", methods=["GET"]) @jwt_required() def get_transaction(transaction_id): transaction = get_transaction_from_database(transaction_id) transaction_schema = TransactionSchema() return transaction_schema.jsonify(transaction) -@endpoints.route('/transactions/', methods=['PUT']) + +@endpoints.route("/transactions/", methods=["PUT"]) @jwt_required() def update_transaction(transaction_id): transaction = get_transaction_from_database(transaction_id) @@ -65,9 +74,10 @@ def update_transaction(transaction_id): # Update transaction in the database return transaction_schema.jsonify(transaction) -@endpoints.route('/transactions/', methods=['DELETE']) + +@endpoints.route("/transactions/", methods=["DELETE"]) @jwt_required() def delete_transaction(transaction_id): transaction = get_transaction_from_database(transaction_id) # Delete transaction from the database - return '', 204 + return "", 204 From 01da4bfbfb5e7981e62c8516f58bfa83d43cabff Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:06:36 +0000 Subject: [PATCH 38/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 2e00c22 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- api/serializers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/serializers.py b/api/serializers.py index 881af2596..ad0d700fe 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -1,11 +1,13 @@ from marshmallow import Schema, fields + class UserSchema(Schema): id = fields.Int(dump_only=True) name = fields.Str(required=True) email = fields.Email(required=True) password = fields.Str(required=True, load_only=True) + class TransactionSchema(Schema): id = fields.Int(dump_only=True) user_id = fields.Int(required=True) From 537d2ac0c70e078777e5ca862c79c2fea9b283b2 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:07:24 +0000 Subject: [PATCH 39/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 3358225 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- api/test_endpoints.py | 136 +++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 74 deletions(-) diff --git a/api/test_endpoints.py b/api/test_endpoints.py index 805c982cc..864c6d238 100644 --- a/api/test_endpoints.py +++ b/api/test_endpoints.py @@ -1,7 +1,10 @@ import unittest + from app import create_app + from api.endpoints import endpoints -from api.serializers import UserSchema, TransactionSchema +from api.serializers import TransactionSchema, UserSchema + class TestEndpoints(unittest.TestCase): def setUp(self): @@ -16,11 +19,11 @@ def tearDown(self): def test_create_user(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password': 'testpassword' + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - response = self.client.post('/api/users', json=user_data) + response = self.client.post("/api/users", json=user_data) self.assertEqual(response.status_code, 201) user_schema = UserSchema() user = user_schema.load(response.get_json()) @@ -28,54 +31,51 @@ def test_create_user(self): def test_get_user(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password': 'testpassword' + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - self.client.post('/api/users', json=user_data) - response = self.client.get('/api/users/1') + self.client.post("/api/users", json=user_data) + response = self.client.get("/api/users/1") self.assertEqual(response.status_code, 200) user_schema = UserSchema() user = user_schema.load(response.get_json()) - self.assertEqual(user.name, 'Test User') - self.assertEqual(user.email, 'test@example.com') + self.assertEqual(user.name, "Test User") + self.assertEqual(user.email, "test@example.com") def test_update_user(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password': 'testpassword' + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - self.client.post('/api/users', json=user_data) - user_data['name'] = 'Updated Test User' - response = self.client.put('/api/users/1', json=user_data) + self.client.post("/api/users", json=user_data) + user_data["name"] = "Updated Test User" + response = self.client.put("/api/users/1", json=user_data) self.assertEqual(response.status_code, 200) user_schema = UserSchema() user = user_schema.load(response.get_json()) - self.assertEqual(user.name, 'Updated Test User') + self.assertEqual(user.name, "Updated Test User") def test_delete_user(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password': 'testpassword' + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - self.client.post('/api/users', json=user_data) - response = self.client.delete('/api/users/1') + self.client.post("/api/users", json=user_data) + response = self.client.delete("/api/users/1") self.assertEqual(response.status_code, 204) def test_create_transaction(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password': 'testpassword' - } - self.client.post('/api/users', json=user_data) - transaction_data = { - 'user_id': 1, - 'amount': 100.0 + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - response = self.client.post('/api/transactions', json=transaction_data) + self.client.post("/api/users", json=user_data) + transaction_data = {"user_id": 1, "amount": 100.0} + response = self.client.post("/api/transactions", json=transaction_data) self.assertEqual(response.status_code, 201) transaction_schema = TransactionSchema() transaction = transaction_schema.load(response.get_json()) @@ -83,17 +83,14 @@ def test_create_transaction(self): def test_get_transactions(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password':'testpassword' + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - self.client.post('/api/users', json=user_data) - transaction_data = { - 'user_id': 1, - 'amount': 100.0 - } - self.client.post('/api/transactions', json=transaction_data) - response = self.client.get('/api/transactions') + self.client.post("/api/users", json=user_data) + transaction_data = {"user_id": 1, "amount": 100.0} + self.client.post("/api/transactions", json=transaction_data) + response = self.client.get("/api/transactions") self.assertEqual(response.status_code, 200) transaction_schema = TransactionSchema(many=True) transactions = transaction_schema.load(response.get_json()) @@ -101,17 +98,14 @@ def test_get_transactions(self): def test_get_transaction(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password': 'testpassword' - } - self.client.post('/api/users', json=user_data) - transaction_data = { - 'user_id': 1, - 'amount': 100.0 + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - self.client.post('/api/transactions', json=transaction_data) - response = self.client.get('/api/transactions/1') + self.client.post("/api/users", json=user_data) + transaction_data = {"user_id": 1, "amount": 100.0} + self.client.post("/api/transactions", json=transaction_data) + response = self.client.get("/api/transactions/1") self.assertEqual(response.status_code, 200) transaction_schema = TransactionSchema() transaction = transaction_schema.load(response.get_json()) @@ -119,18 +113,15 @@ def test_get_transaction(self): def test_update_transaction(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password': 'testpassword' + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - self.client.post('/api/users', json=user_data) - transaction_data = { - 'user_id': 1, - 'amount': 100.0 - } - self.client.post('/api/transactions', json=transaction_data) - transaction_data['amount'] = 200.0 - response = self.client.put('/api/transactions/1', json=transaction_data) + self.client.post("/api/users", json=user_data) + transaction_data = {"user_id": 1, "amount": 100.0} + self.client.post("/api/transactions", json=transaction_data) + transaction_data["amount"] = 200.0 + response = self.client.put("/api/transactions/1", json=transaction_data) self.assertEqual(response.status_code, 200) transaction_schema = TransactionSchema() transaction = transaction_schema.load(response.get_json()) @@ -138,15 +129,12 @@ def test_update_transaction(self): def test_delete_transaction(self): user_data = { - 'name': 'Test User', - 'email': 'test@example.com', - 'password': 'testpassword' - } - self.client.post('/api/users', json=user_data) - transaction_data = { - 'user_id': 1, - 'amount': 100.0 + "name": "Test User", + "email": "test@example.com", + "password": "testpassword", } - self.client.post('/api/transactions', json=transaction_data) - response = self.client.delete('/api/transactions/1') + self.client.post("/api/users", json=user_data) + transaction_data = {"user_id": 1, "amount": 100.0} + self.client.post("/api/transactions", json=transaction_data) + response = self.client.delete("/api/transactions/1") self.assertEqual(response.status_code, 204) From 4c4d0a4eca8583f3f293c509a0a3d9ea1af57bfa Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:10:26 +0000 Subject: [PATCH 40/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in d347349 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- blockchain/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blockchain/__init__.py b/blockchain/__init__.py index 2fe5e113f..112888f97 100644 --- a/blockchain/__init__.py +++ b/blockchain/__init__.py @@ -1,6 +1,6 @@ -from .pi_network import PiNetwork -from .ethereum import Ethereum from .bitcoin import Bitcoin from .block import Block from .chain import Blockchain +from .ethereum import Ethereum from .miner import Miner +from .pi_network import PiNetwork From 3c441256b1ac6169c3e0ccefed5bcde929c312fb Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:11:14 +0000 Subject: [PATCH 41/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in c5cbe89 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- blockchain/block.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blockchain/block.py b/blockchain/block.py index ca6f44246..7945ecbae 100644 --- a/blockchain/block.py +++ b/blockchain/block.py @@ -1,6 +1,7 @@ import hashlib import time + class Block: def __init__(self, index, previous_hash, timestamp, data, hash): self.index = index @@ -12,13 +13,13 @@ def __init__(self, index, previous_hash, timestamp, data, hash): @staticmethod def calculate_hash(index, previous_hash, timestamp, data): value = str(index) + str(previous_hash) + str(timestamp) + str(data) - return hashlib.sha256(value.encode('utf-8')).hexdigest() + return hashlib.sha256(value.encode("utf-8")).hexdigest() def __str__(self): - return 'Block: {index}, Previous Hash: {previous_hash}, Timestamp: {timestamp}, Data: {data}, Hash: {hash}'.format( + return "Block: {index}, Previous Hash: {previous_hash}, Timestamp: {timestamp}, Data: {data}, Hash: {hash}".format( index=self.index, previous_hash=self.previous_hash, timestamp=self.timestamp, data=self.data, - hash=self.hash + hash=self.hash, ) From 34420a9a9eb0680432e396af8ebe19d10759c6f0 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:53:25 +0000 Subject: [PATCH 42/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 1fd4140 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- blockchain/chain.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/blockchain/chain.py b/blockchain/chain.py index ad5ad80d5..ee2bc218f 100644 --- a/blockchain/chain.py +++ b/blockchain/chain.py @@ -1,23 +1,35 @@ import hashlib + class Blockchain: def __init__(self): self.chain = [self.create_genesis_block()] self.difficulty = 2 def create_genesis_block(self): - return Block(0, '0' * 64, int(time.time()), 'Genesis Block', self.calculate_hash(0, '0' * 64, int(time.time()), 'Genesis Block')) + return Block( + 0, + "0" * 64, + int(time.time()), + "Genesis Block", + self.calculate_hash(0, "0" * 64, int(time.time()), "Genesis Block"), + ) def calculate_hash(self, index, previous_hash, timestamp, data): value = str(index) + str(previous_hash) + str(timestamp) + str(data) - return hashlib.sha256(value.encode('utf-8')).hexdigest() + return hashlib.sha256(value.encode("utf-8")).hexdigest() def is_chain_valid(self, chain): for i in range(1, len(chain)): current_block = chain[i] previous_block = chain[i - 1] - if current_block.hash != self.calculate_hash(current_block.index, current_block.previous_hash, current_block.timestamp, current_block.data): + if current_block.hash != self.calculate_hash( + current_block.index, + current_block.previous_hash, + current_block.timestamp, + current_block.data, + ): return False if current_block.previous_hash != previous_block.hash: @@ -26,8 +38,15 @@ def is_chain_valid(self, chain): return True def add_block(self, data): - new_block = Block(len(self.chain), self.chain[-1].hash, int(time.time()), data, None) - new_block.hash = self.calculate_hash(new_block.index, new_block.previous_hash, new_block.timestamp, new_block.data) + new_block = Block( + len(self.chain), self.chain[-1].hash, int(time.time()), data, None + ) + new_block.hash = self.calculate_hash( + new_block.index, + new_block.previous_hash, + new_block.timestamp, + new_block.data, + ) self.chain.append(new_block) def replace_chain(self, chain): From 6d6bdca1d1507dba670ca96c2e47b732d626c0f5 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:56:12 +0000 Subject: [PATCH 43/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 06f5ed4 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- blockchain/miner.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/blockchain/miner.py b/blockchain/miner.py index 2a0a17daf..024156d65 100644 --- a/blockchain/miner.py +++ b/blockchain/miner.py @@ -1,6 +1,8 @@ import time + from blockchain.block import Blockchain + class Miner: def __init__(self, blockchain): self.blockchain = blockchain @@ -9,12 +11,12 @@ def mine_block(self, data): while True: if self.blockchain.is_chain_valid(self.blockchain.chain): self.blockchain.add_block(data) - print('Block successfully mined!') - print('Proof of work: {}'.format(self.blockchain.chain[-1].hash)) + print("Block successfully mined!") + print("Proof of work: {}".format(self.blockchain.chain[-1].hash)) break else: - print('Block not mined. Invalid chain.') + print("Block not mined. Invalid chain.") self.blockchain.chain = [self.blockchain.create_genesis_block()] self.blockchain.difficulty += 1 - print('New difficulty: {}'.format(self.blockchain.difficulty)) + print("New difficulty: {}".format(self.blockchain.difficulty)) time.sleep(1) From 7bce9ca76845ee780b2329274bc3d262577448e8 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 14:00:45 +0000 Subject: [PATCH 44/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 14e3e1d according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- blockchain/test/test_blockchain.py | 50 +++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/blockchain/test/test_blockchain.py b/blockchain/test/test_blockchain.py index bd7e51ad8..d3217a024 100644 --- a/blockchain/test/test_blockchain.py +++ b/blockchain/test/test_blockchain.py @@ -1,6 +1,8 @@ import unittest + from blockchain import Blockchain + class TestBlockchain(unittest.TestCase): def setUp(self): self.blockchain = Blockchain() @@ -8,40 +10,66 @@ def setUp(self): def test_create_genesis_block(self): genesis_block = self.blockchain.create_genesis_block() self.assertEqual(genesis_block.index, 0) - self.assertEqual(genesis_block.previous_hash, '0' * 64) + self.assertEqual(genesis_block.previous_hash, "0" * 64) self.assertIsNotNone(genesis_block.timestamp) - self.assertEqual(genesis_block.data, 'Genesis Block') - self.assertEqual(genesis_block.hash, '0' * 64) + self.assertEqual(genesis_block.data, "Genesis Block") + self.assertEqual(genesis_block.hash, "0" * 64) def test_calculate_hash(self): block = self.blockchain.create_genesis_block() - block.data = 'New Data' + block.data = "New Data" block.hash = None - calculated_hash = self.blockchain.calculate_hash(block.index, block.previous_hash, block.timestamp, block.data) - self.assertEqual(calculated_hash, '0' * 64) + calculated_hash = self.blockchain.calculate_hash( + block.index, block.previous_hash, block.timestamp, block.data + ) + self.assertEqual(calculated_hash, "0" * 64) def test_is_chain_valid(self): self.assertTrue(self.blockchain.is_chain_valid(self.blockchain.chain)) invalid_chain = self.blockchain.chain[:-1] - invalid_chain.append(Block(len(invalid_chain), invalid_chain[-1].hash, int(time.time()), 'Invalid Data', None)) + invalid_chain.append( + Block( + len(invalid_chain), + invalid_chain[-1].hash, + int(time.time()), + "Invalid Data", + None, + ) + ) self.assertFalse(self.blockchain.is_chain_valid(invalid_chain)) def test_add_block(self): - self.blockchain.add_block('Test Data') + self.blockchain.add_block("Test Data") self.assertEqual(len(self.blockchain.chain), 2) - self.assertEqual(self.blockchain.chain[-1].data, 'Test Data') + self.assertEqual(self.blockchain.chain[-1].data, "Test Data") def test_replace_chain(self): self.blockchain.replace_chain(self.blockchain.chain[:-1]) self.assertEqual(len(self.blockchain.chain), 1) invalid_chain = self.blockchain.chain[:-1] - invalid_chain.append(Block(len(invalid_chain), invalid_chain[-1].hash, int(time.time()), 'Invalid Data', None)) + invalid_chain.append( + Block( + len(invalid_chain), + invalid_chain[-1].hash, + int(time.time()), + "Invalid Data", + None, + ) + ) self.blockchain.replace_chain(invalid_chain) self.assertFalse(self.blockchain.is_chain_valid(self.blockchain.chain)) valid_chain = self.blockchain.chain[:-1] - valid_chain.append(Block(len(valid_chain), valid_chain[-1].hash, int(time.time()), 'Valid Data', None)) + valid_chain.append( + Block( + len(valid_chain), + valid_chain[-1].hash, + int(time.time()), + "Valid Data", + None, + ) + ) self.blockchain.replace_chain(valid_chain) self.assertTrue(self.blockchain.is_chain_valid(self.blockchain.chain)) From ecf25cd9108f4b2b720e131af72eff704303edfa Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 14:11:35 +0000 Subject: [PATCH 45/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 0b45323 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- banking/account_management.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/banking/account_management.py b/banking/account_management.py index 1fe44c0e3..4a41344cd 100644 --- a/banking/account_management.py +++ b/banking/account_management.py @@ -3,6 +3,7 @@ import logging from typing import Dict + def create_account(account_type: str, balance: float, customer_id: int) -> Dict: """ Create a new account for a customer. @@ -18,22 +19,23 @@ def create_account(account_type: str, balance: float, customer_id: int) -> Dict: # implementation logging.info(f"Creating account for customer {customer_id}") # Validate input parameters - if account_type not in ['checking', 'savings']: + if account_type not in ["checking", "savings"]: raise ValueError("Invalid account type") if balance < 0: raise ValueError("Balance cannot be negative") # Create account and store it in a database or in-memory data structure account = { - 'id': generate_unique_id(), - 'type': account_type, - 'balance': balance, - 'customer_id': customer_id + "id": generate_unique_id(), + "type": account_type, + "balance": balance, + "customer_id": customer_id, } # Return the account information return account + def update_account(account_id: int, account_type: str, balance: float) -> bool: """ Update an existing account. @@ -49,7 +51,7 @@ def update_account(account_id: int, account_type: str, balance: float) -> bool: # implementation logging.info(f"Updating account {account_id}") # Validate input parameters - if account_type not in ['checking', 'savings']: + if account_type not in ["checking", "savings"]: raise ValueError("Invalid account type") if balance < 0: raise ValueError("Balance cannot be negative") @@ -58,8 +60,8 @@ def update_account(account_id: int, account_type: str, balance: float) -> bool: account = get_account_by_id(account_id) # Update the account information - account['type'] = account_type - account['balance'] = balance + account["type"] = account_type + account["balance"] = balance # Save the updated account back to the database or in-memory data structure save_account(account) @@ -67,6 +69,7 @@ def update_account(account_id: int, account_type: str, balance: float) -> bool: # Return True to indicate success return True + def delete_account(account_id: int) -> bool: """ Delete an account. From 46915ef9d739c661aea2a8a1e2244c7e7d9a8665 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 14:37:40 +0000 Subject: [PATCH 46/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 388f2b4 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- blockchain/transaction.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/blockchain/transaction.py b/blockchain/transaction.py index 79eb547a5..0a49fcf79 100644 --- a/blockchain/transaction.py +++ b/blockchain/transaction.py @@ -5,4 +5,11 @@ def __init__(self, sender, receiver, amount): self.amount = amount def to_string(self): - return "Sender: " + self.sender + ", Receiver: " + self.receiver + ", Amount: " + str(self.amount) + return ( + "Sender: " + + self.sender + + ", Receiver: " + + self.receiver + + ", Amount: " + + str(self.amount) + ) From 709cd5d3a41f1ee152df2d3c4f1ea773775e7875 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:02:01 +0700 Subject: [PATCH 47/59] Update bank.py --- banking/bank.py | 59 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/banking/bank.py b/banking/bank.py index 7123803b8..f60deb6f8 100644 --- a/banking/bank.py +++ b/banking/bank.py @@ -1,24 +1,33 @@ -from banking.accounts import BankAccount -from banking.transactions import transfer +from banking.accounts import BankAccount, SavingsAccount, CheckingAccount, InsufficientFundsError +from banking.transactions import transfer, pay_bill -def create_account(account_number): +def create_account(account_type, account_number): """ - Creates a new bank account with the specified account number. + Creates a new bank account with the specified account type and account number. """ - return BankAccount(account_number) + if account_type == "savings": + account = SavingsAccount(account_number) + elif account_type == "checking": + account = CheckingAccount(account_number) + else: + raise ValueError(f"Invalid account type: {account_type}") + + return account def get_account(account_number): """ -Retrieves the bank account with the specified account number. + Retrieves the bank account with the specified account number. """ # Load account data from database or other storage system account_data = load_account_data(account_number) # Create new account if it doesn't exist if account_data is None: - account = create_account(account_number) + account_type = None else: - account = BankAccount(account_number, balance=account_data["balance"]) + account_type = account_data["type"] + + account = create_account(account_type, account_number) return account @@ -27,17 +36,35 @@ def save_account(account): Saves the specified bank account to the database or other storage system. """ # Save account data to database or other storage system - save_account_data(account.account_number, account.balance) + save_account_data(account.account_number, account.type, account.balance) def process_transaction(transaction): """ - Processes the specified transaction by transferring funds between bank accounts. + Processes the specified transaction by transferring funds between bank accounts or paying a bill. """ - from_account = get_account(transaction["from_account"]) - to_account = get_account(transaction["to_account"]) - amount = transaction["amount"] + transaction_type = transaction["type"] + + if transaction_type == "transfer": + from_account_number = transaction["from_account"] + to_account_number = transaction["to_account"] + amount = transaction["amount"] + + from_account = get_account(from_account_number) + to_account = get_account(to_account_number) + + transfer(from_account, to_account, amount) + + save_account(from_account) + save_account(to_account) + + elif transaction_type == "pay_bill": + account_number = transaction["account"] + payee = transaction["payee"] + amount = transaction["amount"] + due_date = transaction["due_date"] + + account = get_account(account_number) - transfer(from_account, to_account, amount) + pay_bill(account, payee, amount, due_date) - save_account(from_account) - save_account(to_account) + save_account(account) From d65299243edd2a37ee3ff8ca1e6c9824cc4aff54 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 15:02:21 +0000 Subject: [PATCH 48/59] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 709cd5d according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- banking/bank.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/banking/bank.py b/banking/bank.py index f60deb6f8..aad97015f 100644 --- a/banking/bank.py +++ b/banking/bank.py @@ -1,5 +1,11 @@ -from banking.accounts import BankAccount, SavingsAccount, CheckingAccount, InsufficientFundsError -from banking.transactions import transfer, pay_bill +from banking.accounts import ( + BankAccount, + CheckingAccount, + InsufficientFundsError, + SavingsAccount, +) +from banking.transactions import pay_bill, transfer + def create_account(account_type, account_number): """ @@ -14,6 +20,7 @@ def create_account(account_type, account_number): return account + def get_account(account_number): """ Retrieves the bank account with the specified account number. @@ -31,6 +38,7 @@ def get_account(account_number): return account + def save_account(account): """ Saves the specified bank account to the database or other storage system. @@ -38,6 +46,7 @@ def save_account(account): # Save account data to database or other storage system save_account_data(account.account_number, account.type, account.balance) + def process_transaction(transaction): """ Processes the specified transaction by transferring funds between bank accounts or paying a bill. From 9d01cd8c7d466436a10ea4f5a46e51fe8478af71 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:17:52 +0700 Subject: [PATCH 49/59] Create node.js.yml --- .github/workflows/node.js.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 000000000..6d573d77d --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test From d4d7f1f3be260336bdeb5735909cdcaa93bbc68b Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:18:25 +0700 Subject: [PATCH 50/59] Create webpack.yml --- .github/workflows/webpack.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/webpack.yml diff --git a/.github/workflows/webpack.yml b/.github/workflows/webpack.yml new file mode 100644 index 000000000..25e64c08e --- /dev/null +++ b/.github/workflows/webpack.yml @@ -0,0 +1,28 @@ +name: NodeJS with Webpack + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Build + run: | + npm install + npx webpack From f11ed59657a827f2703305dbfe919f1815ba8fc5 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:19:07 +0700 Subject: [PATCH 51/59] Create ruby.yml --- .github/workflows/ruby.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/ruby.yml diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 000000000..5d80832d3 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,38 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: Ruby + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['2.6', '2.7', '3.0'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, + # change this to (see https://github.com/ruby/setup-ruby#versioning): + # uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Run tests + run: bundle exec rake From d0119f2e9f9ebda487748951e2cbea8d1d8645d3 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:19:55 +0700 Subject: [PATCH 52/59] Create symfony.yml --- .github/workflows/symfony.yml | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/symfony.yml diff --git a/.github/workflows/symfony.yml b/.github/workflows/symfony.yml new file mode 100644 index 000000000..e9b7c26f6 --- /dev/null +++ b/.github/workflows/symfony.yml @@ -0,0 +1,47 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Symfony + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + symfony-tests: + runs-on: ubuntu-latest + steps: + # To automatically get bug fixes and new Php versions for shivammathur/setup-php, + # change this to (see https://github.com/shivammathur/setup-php#bookmark-versioning): + # uses: shivammathur/setup-php@v2 + - uses: shivammathur/setup-php@2cb9b829437ee246e9b3cac53555a39208ca6d28 + with: + php-version: '8.0' + - uses: actions/checkout@v4 + - name: Copy .env.test.local + run: php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');" + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Create Database + run: | + mkdir -p data + touch data/database.sqlite + - name: Execute tests (Unit and Feature tests) via PHPUnit + env: + DATABASE_URL: sqlite:///%kernel.project_dir%/data/database.sqlite + run: vendor/bin/phpunit From c18293e6c63cd553ea37d7a9812467d57c081511 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:20:44 +0700 Subject: [PATCH 53/59] Create dart.yml --- .github/workflows/dart.yml | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/dart.yml diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml new file mode 100644 index 000000000..3383c717e --- /dev/null +++ b/.github/workflows/dart.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Dart + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + # Note: This workflow uses the latest stable version of the Dart SDK. + # You can specify other versions if desired, see documentation here: + # https://github.com/dart-lang/setup-dart/blob/main/README.md + # - uses: dart-lang/setup-dart@v1 + - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 + + - name: Install dependencies + run: dart pub get + + # Uncomment this step to verify the use of 'dart format' on each commit. + # - name: Verify formatting + # run: dart format --output=none --set-exit-if-changed . + + # Consider passing '--fatal-infos' for slightly stricter analysis. + - name: Analyze project source + run: dart analyze + + # Your project will need to have tests in test/ and a dependency on + # package:test for this step to succeed. Note that Flutter projects will + # want to change this to 'flutter test'. + - name: Run tests + run: dart test From 2bbabd0af6f04ee2ba4923b902c3cd4b23e5246a Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:21:35 +0700 Subject: [PATCH 54/59] Create dotnet.yml --- .github/workflows/dotnet.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 000000000..217f7cbec --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,28 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: .NET + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal From 9aa1802e3f93e3c899ae7c1b67fc5dac79c6f55c Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:22:11 +0700 Subject: [PATCH 55/59] Create laravel.yml --- .github/workflows/laravel.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/laravel.yml diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml new file mode 100644 index 000000000..fd8c644e6 --- /dev/null +++ b/.github/workflows/laravel.yml @@ -0,0 +1,35 @@ +name: Laravel + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + laravel-tests: + + runs-on: ubuntu-latest + + steps: + - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e + with: + php-version: '8.0' + - uses: actions/checkout@v4 + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.example', '.env');" + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Generate key + run: php artisan key:generate + - name: Directory Permissions + run: chmod -R 777 storage bootstrap/cache + - name: Create Database + run: | + mkdir -p database + touch database/database.sqlite + - name: Execute tests (Unit and Feature tests) via PHPUnit/Pest + env: + DB_CONNECTION: sqlite + DB_DATABASE: database/database.sqlite + run: php artisan test From 16d3d3297feeb515e3f29740915f57127fddff35 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:22:49 +0700 Subject: [PATCH 56/59] Create go.yml --- .github/workflows/go.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 000000000..0b443f376 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,28 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... From 5b5865f81f0fdc89eb56b545bb94630d66702417 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:23:39 +0700 Subject: [PATCH 57/59] Create r.yml --- .github/workflows/r.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/r.yml diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml new file mode 100644 index 000000000..ed8aacfa6 --- /dev/null +++ b/.github/workflows/r.yml @@ -0,0 +1,40 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# +# See https://github.com/r-lib/actions/tree/master/examples#readme for +# additional example workflows available for the R community. + +name: R + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: macos-latest + strategy: + matrix: + r-version: ['3.6.3', '4.1.1'] + + steps: + - uses: actions/checkout@v4 + - name: Set up R ${{ matrix.r-version }} + uses: r-lib/actions/setup-r@f57f1301a053485946083d7a45022b278929a78a + with: + r-version: ${{ matrix.r-version }} + - name: Install dependencies + run: | + install.packages(c("remotes", "rcmdcheck")) + remotes::install_deps(dependencies = TRUE) + shell: Rscript {0} + - name: Check + run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error") + shell: Rscript {0} From 50d818e8eedcd3416d374b23e1b0127f48a2dc98 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:24:25 +0700 Subject: [PATCH 58/59] Create gradle.yml --- .github/workflows/gradle.yml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 000000000..27400c2ba --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,67 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + + - name: Build with Gradle Wrapper + run: ./gradlew build + + # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). + # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. + # + # - name: Setup Gradle + # uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + # with: + # gradle-version: '8.5' + # + # - name: Build with Gradle 8.5 + # run: gradle build + + dependency-submission: + + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. + # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 From 7962d1d436038a4c59116bd1d4b5b1571eb321b7 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 22:27:34 +0700 Subject: [PATCH 59/59] Create terraform.yml --- .github/workflows/terraform.yml | 93 +++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/terraform.yml diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 000000000..540e8040b --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,93 @@ +# This workflow installs the latest version of Terraform CLI and configures the Terraform CLI configuration file +# with an API token for Terraform Cloud (app.terraform.io). On pull request events, this workflow will run +# `terraform init`, `terraform fmt`, and `terraform plan` (speculative plan via Terraform Cloud). On push events +# to the "main" branch, `terraform apply` will be executed. +# +# Documentation for `hashicorp/setup-terraform` is located here: https://github.com/hashicorp/setup-terraform +# +# To use this workflow, you will need to complete the following setup steps. +# +# 1. Create a `main.tf` file in the root of this repository with the `remote` backend and one or more resources defined. +# Example `main.tf`: +# # The configuration for the `remote` backend. +# terraform { +# backend "remote" { +# # The name of your Terraform Cloud organization. +# organization = "example-organization" +# +# # The name of the Terraform Cloud workspace to store Terraform state files in. +# workspaces { +# name = "example-workspace" +# } +# } +# } +# +# # An example resource that does nothing. +# resource "null_resource" "example" { +# triggers = { +# value = "A example resource that does nothing!" +# } +# } +# +# +# 2. Generate a Terraform Cloud user API token and store it as a GitHub secret (e.g. TF_API_TOKEN) on this repository. +# Documentation: +# - https://www.terraform.io/docs/cloud/users-teams-organizations/api-tokens.html +# - https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets +# +# 3. Reference the GitHub secret in step using the `hashicorp/setup-terraform` GitHub Action. +# Example: +# - name: Setup Terraform +# uses: hashicorp/setup-terraform@v1 +# with: +# cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} + +name: 'Terraform' + +on: + push: + branches: [ "main" ] + pull_request: + +permissions: + contents: read + +jobs: + terraform: + name: 'Terraform' + runs-on: ubuntu-latest + environment: production + + # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest + defaults: + run: + shell: bash + + steps: + # Checkout the repository to the GitHub Actions runner + - name: Checkout + uses: actions/checkout@v4 + + # Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} + + # Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. + - name: Terraform Init + run: terraform init + + # Checks that all Terraform configuration files adhere to a canonical format + - name: Terraform Format + run: terraform fmt -check + + # Generates an execution plan for Terraform + - name: Terraform Plan + run: terraform plan -input=false + + # On push to "main", build or change infrastructure according to Terraform configuration files + # Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks + - name: Terraform Apply + if: github.ref == 'refs/heads/"main"' && github.event_name == 'push' + run: terraform apply -auto-approve -input=false