Does oz check assume all contracts are upgradable?

I’m using oz check on my project, which has one upgradable contract and one non-upgradable contract (Hello.sol), which produces the following issue in red:

Contract Hello or an ancestor has a constructor. Change it to an initializer function. See https://docs.openzeppelin.com/upgrades/2.6//writing-upgradeable#initializers.

and warning in yellow:

Contract Hello imports access/Ownable.sol, GSN/Context.sol, token/ERC20/IERC20.sol, token/ERC20/SafeERC20.sol, math/SafeMath.sol, utils/Address.sol from @openzeppelin/contracts. Use @openzeppelin/contracts-ethereum-package instead. See https://docs.openzeppelin.com/cli/2.6/dependencies#linking-the-contracts-ethereum-package.

// Hello.sol
pragma solidity ^0.6.12;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";

contract Hello is Ownable {
    using SafeERC20 for IERC20;
    using SafeMath for uint256;
    constructor() public {};
}

Why doesn’t oz check Hello.sol as a non-upgradable contract? Could it concern the fact that the issues/warnings are pointing to CLI 2.6 docs, while IIRC non-upgradable contracts are only supported from the CLI in 2.8? I’ve npm installed @openzeppelin/cli: "^2.8.2".

1 Like

Hi @dtp5,

I assume that npx oz check treats contracts as upgradeable.

Though I haven’t been able to generate warnings with your contract other than SPDX License Identifier warnings.

One thing to note, is that your constructor has an erroneous semicolon. I assume this is where you have cut down your contract.

$ npx oz check
✖ Compiling contracts with solc 0.6.12 (commit.27d51765)
Compilation errors:
contracts/Hello.sol:12:28: ParserError: Function, variable, struct or modifier declaration expected.
    constructor() public {};