Relevance of the ‘complexity factor’ in the studies of relativistic self-gravitating objects has become an area of intense research in recent years. To investigate the role of various factors contributing to the ‘complexity factor’ and subsequent occurrence of ‘cracking’ within a self-gravitating star, in this paper, we develop a new class of exact solutions to a spherically symmetric and static stellar configuration in the presence of charge and anisotropic pressure. Some of the stellar models studied earlier are shown to be sub-class our solutions. Making use of one particular class of solutions, we analyze the impacts of charge and anisotropic stress on the complexity factor of a given stellar configuration where the complexity factor is interpreted in terms of the definition put forward by Herrera [Phys. Rev. D 97 (2018) 44010]. While, even in the presence of charge and anisotropic stress of an inhomogeneous stellar configuration, the complexity factor might vanish, we show that the complexity factor usually increases in the presence of charge and anisotropy.